Datalist Textbox Values

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
 
D

David Jessee

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
 
G

Guest

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
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top