Specified argument was out of the range of valid values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RN1

    Specified argument was out of the range of valid values

    I have a DataGrid with 7 BoundColumns. A user can login as an admin or
    non-admin. When a user logs in as a non-admin & the DatGrid is in the
    editable mode, I want only the first 4 columns i.e. the TextBoxes in
    the first 4 columns to be editable & the remaining 3 TextBoxes should
    remain disabled. This is what I tried (in the OnItemDataBound event
    functions):

    --------------------
    If (sessAdmin = 0) Then
    For i = 4 To 6
    CType(ea.Item.C ells(i).Control s(0), TextBox).Enable d = False
    Next
    End If
    --------------------

    But the above code generates the following error:

    --------------------
    Specified argument was out of the range of valid values.
    Parameter name: index
    --------------------

    Since the columns are BoundColumns, if I am not mistaken, the
    TextBoxes (when the DataGrid is in the editable mode) ought to be
    Controls(0) & Cells(4) to Cells(6) are very much present. So why is
    this error getting generated?

    I even tried the above code in the OnEditCommand event function of the
    DataGrid but the same error gets generated.
  • Patrice

    #2
    Re: Specified argument was out of the range of valid values

    My first move would be just to use UBound and/or Count to make sure my
    assumptions are valid.

    --
    Patrice


    "RN1" <rn5a@rediffmai l.coma écrit dans le message de groupe de discussion
    : f3d22b66-5bac-43ab-9399-a67118a37df1...le groups.com...
    I have a DataGrid with 7 BoundColumns. A user can login as an admin or
    non-admin. When a user logs in as a non-admin & the DatGrid is in the
    editable mode, I want only the first 4 columns i.e. the TextBoxes in
    the first 4 columns to be editable & the remaining 3 TextBoxes should
    remain disabled. This is what I tried (in the OnItemDataBound event
    functions):
    >
    --------------------
    If (sessAdmin = 0) Then
    For i = 4 To 6
    CType(ea.Item.C ells(i).Control s(0), TextBox).Enable d = False
    Next
    End If
    --------------------
    >
    But the above code generates the following error:
    >
    --------------------
    Specified argument was out of the range of valid values.
    Parameter name: index
    --------------------
    >
    Since the columns are BoundColumns, if I am not mistaken, the
    TextBoxes (when the DataGrid is in the editable mode) ought to be
    Controls(0) & Cells(4) to Cells(6) are very much present. So why is
    this error getting generated?
    >
    I even tried the above code in the OnEditCommand event function of the
    DataGrid but the same error gets generated.

    Comment

    Working...