How to get value from a textbox in DataList

P

Peter Afonin

Hello:

I've never used the DataList before, and I have a problem now:

In the ItemTemplate I put the LinkButton and a TextBox (not databound, I
want the user to be able to type in it). Then I try to retrieve the value of
the textbox by pressing the Linkbutton, like this, pretty much like I do it
in Datagrid:

Private Sub MyList_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs) Handles
MyList.ItemCommand
Try

Dim txt As TextBox
txt = CType(e.Item.FindControl("txtDomain"), TextBox)
Dim sDomain As String = txt.Text
Catch ex As Exception
Response.Write(ex.Message)
Finally
End Try
End Sub

If I type something in this textbox and press the button, the value is
always an emty string. Perhaps I just don't understand how the Datalist
works. What am I doing wrong?

I would appreciate your help.

Thank you,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top