Using C# & Mysql
I have combobox & button in my webpage, if i select a value from the combobox, then i click the button the page is refreshing, combobox value is changing.
For Example
Combobox value: 1, 2, 3, 4 .....
If i selected 2 then i press the button, webpage is refreshing, combobox values is display from: 1, 2, 3, 4....
Combobox should display 2
Why combobox is displaying a selected value when i press the button.
Table Name: user
Name username
Raja 1
Ravi 2
Ram 3
kumar 4
...,
Button click event code
cmd1 = new OdbcCommand("Select name from users where username = '" + combobox1.Items[combobox1.SelectedIndex].Text + "' ", dbcon);
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
textbox1.Text = dr1.GetString(0);
}
dr1.Close();
The Above code is working, but if i select the value 2 from the combobox, then i press the button textbox should display ravi, but textbox is displaying Raja, and also combobox also refreshing, combobox is not displaying 1 instead of 2.
How to solve this issue.
Need C# code Help