problem accessing checkbox in datagrid

Discussion in 'ASP .Net Datagrid Control' started by shalin, Mar 3, 2004.

  1. shalin

    shalin Guest

    hi I have a problem in datagrid

    Actually I am having a two datagrids and some other controls in a
    usercontrol. I have added this user control to a aspx page. On
    clicking a link in the first data grid the second datagrid is
    displayed
    My first datagrid has a checkbox column added using itemtemplate.
    In the usercontrol I have a button called update on which I have to
    see which checkboxes are checked based on which I have to update it to
    the db.

    My problem is when all the controls in the usercontrol are loaded I am
    able to access in the checkbox column in my first datagrid else it
    throws and error

    I have used the following code

    Private Sub UpdateAccountDetails()

    Dim dgItem As DataGridItem
    Dim ctl As Object


    For Each dgItem In AcctsGrid.Items
    ctl = CType(dgItem.Cells(0).Controls(0), CheckBox)

    If Not ctl Is Nothing Then
    Dim nViewSite = CType(ctl, CheckBox).Checked
    If nViewSite = True Then
    'comes inside this if its checked
    End If
    End If
    Next dgItem

    End Sub

    the error is

    Specified argument was out of the range of valid values. Parameter
    name: index
    Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.

    Exception Details: System.ArgumentOutOfRangeException: Specified
    argument was out of the range of valid values. Parameter name: index

    Source Error:


    Line 747: For Each dgItem In AcctsGrid.Items
    Line 748: ctl = CType(dgItem.Cells(0).Controls(0),
    CheckBox)

    Also I want to maintain the checked values even if my page get
    reloaded.please somebody help me out.

    shalin
    shalin, Mar 3, 2004
    #1
    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. tshad
    Replies:
    0
    Views:
    462
    tshad
    Apr 15, 2005
  2. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,344
    ThunderMusic
    Jan 25, 2006
  3. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    767
    David Wier
    Oct 6, 2006
  4. Jason Huang
    Replies:
    0
    Views:
    512
    Jason Huang
    Jun 29, 2007
  5. Joey Pang
    Replies:
    4
    Views:
    485
    Joey Pang
    Jun 13, 2005
Loading...

Share This Page