In my webpage I am using combobox & searchbutton.
When i select a value from combobox then i click the search button, the combobox first matching value is displaying
For Example
- combobox values are – 001, 002, 003
- When i select the value in the combobox -003
- Then i click the search button
- The page is refreshing and 001 values are displaying instead of 003
Code for Search Click button:
cmd2 = new OdbcCommand("Select * from table where id = '" + combobox1.Text + "' ", con);
ada2 = new OdbcDataAdapter(cmd2);
ds1 = new DataSet();
ada2.Fill(ds1);
gridview1.DataSource = ds1;
gridview1.DataBind();
How can I solve this issue?
Are you binding your gridview or combobox in your Page_Load method? I have a hunch this may be the issue. Make sure it looks like this: