scropio gurl

scropio gurl

  • NA
  • 147
  • 99.3k

insert value from dropdown to table

Oct 22 2016 5:20 AM

I try to insert dropdown selected value in table and I am done with this

protected void Button1_Click(object sender, EventArgs e)
{
string Vechile_ID = "";
try
{
Data n = new Data();
tbl_Vechile v = new tbl_Vechile();
v.Vechile_ID = Vechile_ID;
{
v.Vechile_ID = DropDownList1.SelectedValue;
}

n.tbl_Vechile.Add(v).ToString();
n.SaveChanges();

}
catch
{

}
Response.Redirect("Mai.aspx");

}
}

Now the problem is suppose dropdown value are

ERE23
DFG4
ER4

When I select ER4 value then ER4 is inserted in table but when I select again and click on button then value again inserted in table where as I want to insert value only once not wanted to insert same value again and again

How I do this


Answers (5)