OnItemCommand in DataList, how to manipulate controls in Selected Row

Discussion in 'ASP .Net' started by bdwgarth, Jun 22, 2005.

  1. bdwgarth

    bdwgarth Guest

    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
    ---------------------------------------

    Thanks,

    Brett
     
    bdwgarth, Jun 22, 2005
    #1
    1. Advertising

  2. RE: OnItemCommand in DataList, how to manipulate controls in Selected

    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__
    ---_,>/'_------
    (_) \(_)
    ---------------


    "bdwgarth" wrote:

    > 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
    > ---------------------------------------
    >
    > Thanks,
    >
    > Brett
    >
    >
     
    =?Utf-8?B?dmluYXk=?=, Jun 22, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DaWoE

    Datalist onItemCommand not firing

    DaWoE, Jun 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,626
    DaWoE
    Jun 25, 2004
  2. H5N1
    Replies:
    0
    Views:
    2,767
  3. Dave
    Replies:
    1
    Views:
    346
    Mike Wahler
    Jan 22, 2005
  4. OnItemCommand DataList

    , Nov 22, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    383
  5. Svein Terje Gaup

    DataList OnItemCommand is not triggered

    Svein Terje Gaup, Jul 12, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    219
    Svein Terje Gaup
    Jul 12, 2006
Loading...

Share This Page