itemdatabound error

P

pmuruga

Hi,
I am a newbie using the datagrid. I got a code snippet from
gotdotnet. I have a edit command column and 3 bound column. when i try
to edit the record i get an error.

Sub MyDataGrid_ItemDataBound(ByVal Sender As Object, ByVal E As
DataGridItemEventArgs)
If (E.Item.ItemType = ListItemType.EditItem) Then
Dim i As Integer
For i = 0 To E.Item.Controls.Count - 1
If (E.Item.Controls(i).Controls(0).GetType().ToString()
= "System.Web.UI.WebControls.TextBox") Then
Dim tb As TextBox
tb = E.Item.Controls(i).Controls(0)
tb.Text = Server.HtmlDecode(tb.Text)
End If
Next
End If
End Sub

when the count goes to 1 and greater I get specified argument was out
of range. I tried debugging and I can see that
E.Item.Controls(0).Controls(0).GetType().ToString() =
System.Web.UI.WebControls.Button
but E.Item.Controls(1).Controls(0).GetType().ToString() is throwing an
error.

Any help would be appreciated.

Thank you,
Muru
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top