I hope this is as simple as I think it is, but for some reason, I cannot see the forest through the trees. On my page I have a datalist that, during edit mode, displays several text boxes for the user to type in. What I want to is poll a database after the user types in a value into say 'TextBox1'. I just cannot figure out the correct path to the TextBox events when it's a part of the DataList Edit section. Any ideas ? Thanks.It took some digging, but I finally figured out the code to access a textbox within a datalist (thanks to all who helped). I have added the code below and attempted to explain what's going on, but I may not have the wording exactly correct.
Dim i As Integer
Dim crt As Control
Find the datalist control on the page
For i = 0 To Me.DataList.Controls.Count 1
Once the datalist is found, find the textbox control within the datalist
For Each crt In Me.DataList.Controls(i).Controls
Establish a connection to the datalist control line
Dim item As DataListItem = Me.DataList.Controls(i)
Find the text box within the row
Dim tbx As System.Web.UI.WebControls.TextBox =item.FindControl("TextBox1")
If (crt.ID = "TextBox1") Then
If tbx.Text = "Hi" Then
tbx.Text = "Hi There"
Else
tbx.Text = "Bye then"
End If
End If
Next
Next
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment