OnItemCommand in DataList, how to manipulate controls in Selected Row

  • Thread starter Thread starter bdwgarth
  • Start date Start date
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
 
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__
---_,>/'_------
(_) \(_)
 
Back
Top