By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,876 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,876 IT Pros & Developers. It's quick & easy.

DataList + CheckBox

P: n/a
I have a DataList with a lot of items where the user can select them trough
the CheckBoxes but i don't have idea how to capture these values from the
checkboxes to insert in my DataBase....How to accomplish that ?

--
Please, check my theSpoke:
http://www.thespoke.net/MyBlog/dgroh/MyBlog.aspx
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You have to iterate through each item in the datalist find the checkbox
control and check if it is selected. assuming your datalist's id is dl and
the checkbox id is controlsid

Dim alSelectedValues As New ArrayList

For Each item As DataListItem In dl.Items
'check the item isn't a header or footer
If item.itemindex > -1 Then
Dim cb As CheckBox = item.FindControl("controlsid")

Dim value As String = cb.Text
Dim checked As Boolean = cb.Checked

If checked Then
alSelectedValues.Add(value)
End If
End If

Next

good luck jd

"Paperback Writer" wrote:
I have a DataList with a lot of items where the user can select them trough
the CheckBoxes but i don't have idea how to capture these values from the
checkboxes to insert in my DataBase....How to accomplish that ?

--
Please, check my theSpoke:
http://www.thespoke.net/MyBlog/dgroh/MyBlog.aspx

Nov 19 '05 #2

P: n/a
This code is OK only for Datagrid not only for Datalist. I search the way to
access the footer data from outside of dataset event. If u have, pls inform
me.
Kaung Htut Oo
Kh*****@gmail.com
"london calling" wrote:
You have to iterate through each item in the datalist find the checkbox
control and check if it is selected. assuming your datalist's id is dl and
the checkbox id is controlsid

Dim alSelectedValues As New ArrayList

For Each item As DataListItem In dl.Items
'check the item isn't a header or footer
If item.itemindex > -1 Then
Dim cb As CheckBox = item.FindControl("controlsid")

Dim value As String = cb.Text
Dim checked As Boolean = cb.Checked

If checked Then
alSelectedValues.Add(value)
End If
End If

Next

good luck jd

"Paperback Writer" wrote:
I have a DataList with a lot of items where the user can select them trough
the CheckBoxes but i don't have idea how to capture these values from the
checkboxes to insert in my DataBase....How to accomplish that ?

--
Please, check my theSpoke:
http://www.thespoke.net/MyBlog/dgroh/MyBlog.aspx

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.