Specified argument was out of the range of valid values

R

RN1

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.Cells(i).Controls(0), TextBox).Enabled = 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.
 

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,050
Latest member
AngelS122

Latest Threads

Top