Simple Code For Beinners about DropdownlistBox?

Sabarimahesh
Posted by Sabarimahesh under C# category on | Points: 40 | Views : 942
IF I'm having two textbox...

And I'm Having One DropdownListbox....

When I'm Selected From the DropdownlistBox ...

Then Corresponding details showed in that Textbox...



Coding....




protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

{


con.Open();
SqlCommand cmd1 = new SqlCommand("select username,password from tbl_Login where username='"+DropDownList1.SelectedValue.ToString()+"'", con);
cmd1.CommandType = CommandType.Text;
SqlDataReader read;
read = cmd1.ExecuteReader();
read.Read();
TextBox1.Text = read.GetValue(0).ToString();
TextBox2.Text = read.GetValue(1).ToString();
read.Close();
con.Close();



}

Comments or Responses

Login to post response