Posted: 12/9/2011
i am new to asp .net . i have created a table in oracle having 2 columns one is for department name and the other is da name of the students . In the asp.net design page i ahve the drop down list where the name of different departments are given( in my case computer, electronics and electrical). i want a code such that when i click on a particular department say electrical then in the list box i get the name of all the students who belong to electrical department . I am unable to do it. i wrote this code but it isnt working..
protected void drpdwndept_SelectedIndexChanged(object sender, EventArgs e) { Class1 ford = new Class1(); int i,k; String sql = "select Department,Name from Result"; OracleDataAdapter da = new OracleDataAdapter(sql, ford.ConnectionString); DataTable dt = new DataTable(); da.Fill(dt); for(i=0;i<dt.Rows.Count;i++) { if(drpdwndept.SelectedItem.Text==dt.Rows[i][0].ToString()) { k=i; lstboxstudents.Items.Add (dt.Rows[k][1].ToString()); } }
Posted: 12/15/2011
See if this helps: http://forums.asp.net/t/1431726.aspx/1