on listbox selected index changed problem
Revision 2
In my project I bind a listbox1 with say 60px height. When I select an item (for raising another listbox2, using the selected item) that is beneath the 60px height using vertical scroll bar, the status of the listbox is returning back to the first position thereby the selected item goes unknown for the user. Is there any facility to retain the status of listbox on that selected item itself.
Regards.
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (ListBox1.SelectedIndex == 0)
{
}
else
{
SqlDataAdapter da1 = new SqlDataAdapter("select block_name,block_code from block where dist_code='" + v_dist_code + "'", con);
SqlCommandBuilder cb1 = new SqlCommandBuilder(da1);
DataSet ds1 = new DataSet("block");
da1.Fill(ds1, "block");
for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
{
List adds1 = new List();
adds1.Add(ds1.Tables[0].Rows[i].ItemArray[0].ToString());
string name1 = ds1.Tables[0].Rows[i]["block_name"].ToString();
if (name1 == ListBox1.SelectedValue)
{
v_block_code = Convert.ToInt32(ds1.Tables[0].Rows[i]["block_code"].ToString());
}
}
}
[EDIT]David_Wimbley: Moved code from comment to question[/EDIT]
Posted 16-Jan-13 21:27pm
by
S.Rajendran from Coimbatore.