Protected void ListBox1_SelectedIndexChanged (object sender, EventArgs e)
{
This. ListBox2.Items. Clear ();
String s = "select * from class where sid = '" + this. ListBox1.SelectedValue + "'";
SqlConnection ccc = new SqlConnection ();
Ccc. ConnectionString = ConfigurationManager. ConnectionStrings ["strcnn"]. ConnectionString;
SqlCommand cmm = new SqlCommand (s, ccc );
Ccc. Open (); // call the database
SqlDataReader myr;
Myr = cmm. ExecuteReader ();
While (myr. Read ())
{
This. ListBox2.Items. Add (new ListItem (myr ["classname"]. ToString (), myr ["id"]. ToString ()));
}
} The code is written in the SelectedIndexChanged attribute of listbox1.
Then, the autopostback is true and can be uploaded to the server.
Then write the code in it to get the selected items of listbox1 and get the data from the database. At this time, you will be able to update the working code.
From the liuningshiwoa Column