about dropdownlist selected change event
Hi,
In my webpage i have a dropdownlist.In this i obtain the items from datasource.say item1,item2....item5.
In the data base each item contains a checkbox with true/false and 2 textboxes namely id and description are stored in one table name "Test"
so in my current web page dropdownlist and 5 checkboxes and textboxes i have placed. whenever the user clicks item form dropdown list exaple item2 based on database "Test" values particular checkbox and textboxes are selected.I have tried this one but i am getting only First record in the "Test" table.How could record pointer moves based on selection of item in drop downlist.
I am showing my code.pls solve my problem
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
cmd.CommandText = "select stage1checked,id1,des1,stage2checked,id2,des2,stag e3checked,id3,des3,stage4checked,id4,des4,stage5ch ecked,id5,des5 from stage"
cmd.Connection = con
con.Open()
dr = cmd.ExecuteReader()
If dr.Read Then
CheckBox1.Checked = dr.Item(0)
TextBox4.Text = dr.Item(1)
TextBox11.Text = dr.Item(2)
CheckBox2.Checked = dr.Item(3)
TextBox5.Text = dr.Item(4)
TextBox12.Text = dr.Item(5)
CheckBox3.Checked = dr.Item(6)
TextBox6.Text = dr.Item(7)
TextBox13.Text = dr.Item(8)
CheckBox4.Checked = dr.Item(9)
TextBox7.Text = dr.Item(10)
TextBox14.Text = dr.Item(11)
CheckBox5.Checked = dr.Item(12)
TextBox8.Text = dr.Item(13)
TextBox15.Text = dr.Item(14)
Else
dr.Close()
con.Close()
End If
End Sub
|