D
Dharmen
Hey guys!
I wrote a script with 2 dropdown lists. When the value on one is
selected it should automatically load the corresponding value from the table
on the second list. This for some apparent reason is not working.
Label1.Text=this.ddList1.SelectedItem.ToString();
SqlCommand sqlCmd2 =new SqlCommand("SELECT Name FROM pricesTB1 WHERE
Location="+Label1.Text,conn);
conn.Open();
SqlDataReader read2=sqlCmd2.ExecuteReader();
while (read2.Read())
{
//ListItem NewItem2 = new ListItem();
//NewItem2.Text=read2.GetString(0);
//NewItem2.Value = read2.GetValue(0).ToString();
//ddList2.Items.Add(NewItem2);
Label2.Text=this.ddList1.SelectedItem.ToString();
}
conn.Close();
It works fine when i explicitely define the SQL Command but when i read it
using this.ddList1.SelectedItem.ToString();
it messes up...Please help me.
Thanks
I wrote a script with 2 dropdown lists. When the value on one is
selected it should automatically load the corresponding value from the table
on the second list. This for some apparent reason is not working.
Label1.Text=this.ddList1.SelectedItem.ToString();
SqlCommand sqlCmd2 =new SqlCommand("SELECT Name FROM pricesTB1 WHERE
Location="+Label1.Text,conn);
conn.Open();
SqlDataReader read2=sqlCmd2.ExecuteReader();
while (read2.Read())
{
//ListItem NewItem2 = new ListItem();
//NewItem2.Text=read2.GetString(0);
//NewItem2.Value = read2.GetValue(0).ToString();
//ddList2.Items.Add(NewItem2);
Label2.Text=this.ddList1.SelectedItem.ToString();
}
conn.Close();
It works fine when i explicitely define the SQL Command but when i read it
using this.ddList1.SelectedItem.ToString();
it messes up...Please help me.
Thanks