I have a dataGrid with a dataList within. The dataList has a checkbox and I need to grab all the checked items from the Datalist.
My code is giving me all the checkboxes including the unchecked boxes multiple times.
How do I only get the checked items Please note I am not sending data to database yet, I am checking the data first. Can someone please share your expertise in making this happen. Your help is greatly appriecated.
thank you much..... Is it possible that my for loops are not in the correct order.
'My Code:
'Setup for selected items
Dim myList As New List(Of Integer)
'Iterates through the rows of the DataList control
For Each x As DataListItem In dlClientBusiness.Items
For i As Integer = 0 To dlClientBusiness.Items.Count - 1
Dim DLCkBox As CheckBox = DirectCast(dlClientBusiness.Items(i).FindControl("ckBox"), CheckBox)
Dim lblDDParentID As Label = DirectCast(dlClientBusiness.Items(i).FindControl("lblDDParentID"), Label)
Dim lblDLUniqueID As Label = DirectCast(dlClientBusiness.Items(i).FindControl("lblDLUniqueID"), Label)
If DLCkBox.Checked = True And DLCkBox.Visible = True Then
myList.Add(lblDLUniqueID.Text)
'setting up MyList
End If
Next
Next
'Save to database
Dim eFlag As Boolean = False
For x As Integer = 0 To myList.Count - 1
'send to Class
xUserAccess.addUserAccess(xUserName, tlrDataPicker.SelectedDate, myList(x))
'testing show data input- Here I am checking for checked items
-I get the checked items but duplications. I need to only get the checked items without duplications.
lblSelectedItems.Text &= myList(x) & tlrDataPicker.SelectedDate & "<br />" lblSelectedItems.Text &= "______________________________<br /><br />"
'check for errors
If xUserAccess.errorFlag Then
eFlag = True
End If
Next
slimbunny
Member
437 Points
508 Posts
Get all dataList Checkboxes ....
Feb 21, 2012 08:48 PM|LINK
HELP PLEASE...
I have a dataGrid with a dataList within. The dataList has a checkbox and I need to grab all the checked items from the Datalist.
My code is giving me all the checkboxes including the unchecked boxes multiple times. How do I only get the checked items Please note I am not sending data to database yet, I am checking the data first. Can someone please share your expertise in making this happen. Your help is greatly appriecated. thank you much..... Is it possible that my for loops are not in the correct order.
'My Code:
'Setup for selected items
Dim myList As New List(Of Integer)
'Iterates through the rows of the DataList control
For Each x As DataListItem In dlClientBusiness.Items
For i As Integer = 0 To dlClientBusiness.Items.Count - 1
Dim DLCkBox As CheckBox = DirectCast(dlClientBusiness.Items(i).FindControl("ckBox"), CheckBox)
Dim lblDDParentID As Label = DirectCast(dlClientBusiness.Items(i).FindControl("lblDDParentID"), Label)
Dim lblDLUniqueID As Label = DirectCast(dlClientBusiness.Items(i).FindControl("lblDLUniqueID"), Label)
If DLCkBox.Checked = True And DLCkBox.Visible = True Then
myList.Add(lblDLUniqueID.Text) 'setting up MyList
End If
Next
Next
'Save to database
Dim eFlag As Boolean = False
For x As Integer = 0 To myList.Count - 1
'send to Class
xUserAccess.addUserAccess(xUserName, tlrDataPicker.SelectedDate, myList(x))
'testing show data input - Here I am checking for checked items - I get the checked items but duplications. I need to only get the checked items without duplications.
lblSelectedItems.Text &= myList(x) & tlrDataPicker.SelectedDate & "<br />"
lblSelectedItems.Text &= "______________________________<br /><br />"
'check for errors
If xUserAccess.errorFlag Then
eFlag = True
End If
Next
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: Get all dataList Checkboxes ....
Feb 23, 2012 07:53 AM|LINK
Hi,
Please refer your another post: http://forums.asp.net/t/1772177.aspx
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework