OnItemCommand in DataList, how to manipulate controls in Selected Row

B

bdwgarth

I am working with a DataList which consists of dynamically changing
number of rows and static number of columns. There are twelve columns
and each is a singe CheckBox representing a Yes or No value(checked or
not checked). I have a 'Check All' button (using OnItemCommand) for
each row that needs check all of the CheckBoxes in that row so the user
dont have to take the time. I can get the row index but how do I go
about setting the boxes to checked only for this row. I have something
like this:

----------------------------------
Dim dl2item As DataListItem
Dim cb1 As CheckBox
Dim cb2 As CheckBox
Dim cb3 As CheckBox
............
Dim cb12 As CheckBox

** Dont know This Part **
** For this row E.Item.ItemIndex I want all boxes checked**

cb1 = CType(dl2item.FindControl("CheckBox1"), CheckBox)
cb2 = CType(dl2item.FindControl("CheckBox2"), CheckBox)
cb3 = CType(dl2item.FindControl("CheckBox3"), CheckBox)
.............
cb12 = CType(dl2item.FindControl("CheckBox12"), CheckBox)

cb1.Checked = True
cb2.Checked = True
cb3.Checked = True
.............
cb12.Checked = True
 
G

Guest

try this if it works

Dim j As Integer
For j = 0 To e.Item.Cells.Count - 1
For Each cntrl As Control In e.Item.Cells(j).Controls
If TypeOf cntrl Is System.Web.UI.WebControls.CheckBox Then
CType(cntrl, CheckBox).Checked = True
End If
Next

Next

--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top