Datalist Textbox Values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All,

I have a datalist whose itemtemplate contains a label and a textbox. The
label text is set on itemdatabound with the text, which is a question, from
the database column. Each question has an associated textbox. I want the user
to put a response to each question in the textbox, and click save. How do I
get the values from the textboxes? Bearing in mind that they all have dynamic
ids.

Thanks all,

Jon
 
you might want to stay away from the dynamic ID's for the text boxes. If
you set the DataKeyField to, lets say a field called "ID" and the textbox is
named TextBox1...

then
dim i as int32 = 3 ' the item you are wanting
dim id as int32 = mylist.DataKeys(i) '' There's your ID
dim s as String =
ctype(mylist.items(i).FindControl("TextBox1"),TextBox).Text

make i a loop counter and you can interate through all of the items
 
David,

Thats's great. Thanks for the help.

Jon

David Jessee said:
you might want to stay away from the dynamic ID's for the text boxes. If
you set the DataKeyField to, lets say a field called "ID" and the textbox is
named TextBox1...

then
dim i as int32 = 3 ' the item you are wanting
dim id as int32 = mylist.DataKeys(i) '' There's your ID
dim s as String =
ctype(mylist.items(i).FindControl("TextBox1"),TextBox).Text

make i a loop counter and you can interate through all of the items
 
Back
Top