Dropdown selectchange problem
Posted on 2005-04-11
I have the following code in a page_load event which fills a dropdownlist named ddl1 and and some other controls .
suppose ddl1 is filled with 1,2,3,4 and values to A,B,C,D
If value retruned from db is 2 then ddl1's selected text will be 2.
When I change ddl1 item to 1 I get A in the txtName textbox as expected. But when I select 2 again I don't get txtName populated with B(nothing get populated), but for all others items I get the corresponding value in the txtName textbox.
could anyone pls. help me to solve the problem?
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
ddl1.DataSource = General.GetDr(sqlText2)
ddl1.DataTextField = "ID"
ddl1.DataValueField = "ProfileInfo"
txtJobCardNo.Text = Request.QueryString("JobCardNo")
Dim rdr As OleDbDataReader = cmd.ExecuteReader
If rdr.Read Then
txtDrawingFile = rdr.Item("DrawingFile")
imgfile.ImageUrl = txtDrawingFile
ddl1.SelectedItem.Text = rdr.Item("D1")
txtName.Text = rdr.Item("Name1")
Private Sub ddl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ddl1.SelectedIndexChanged
If ddl1.SelectedIndex <> 0 Then
txtName.Text = dd1.selectedvalue
txtName.Text = ""