itemdatabound error

Discussion in 'ASP .Net Datagrid Control' started by pmuruga@gmail.com, Sep 22, 2006.

  1. Guest

    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
     
    , Sep 22, 2006
    #1
    1. Advertisements

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. James G. Beldock

    ItemDataBound not received by grid in table?

    James G. Beldock, Jul 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    517
    James G. Beldock
    Jul 24, 2003
  2. Tina
    Replies:
    1
    Views:
    466
    Suresh
    Oct 14, 2003
  3. René Paschold

    Re: ItemDataBound in Repeater: FYI

    René Paschold, Oct 14, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    596
    René Paschold
    Oct 16, 2003
  4. Steve Klett

    inserting control in ItemDataBound

    Steve Klett, Nov 12, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    734
    Steve Klett
    Nov 13, 2003
  5. Peter Afonin
    Replies:
    2
    Views:
    598
    Peter Afonin
    Nov 19, 2003
  6. Josh Daws
    Replies:
    2
    Views:
    24,325
    Claes
    Sep 11, 2006
  7. =?Utf-8?B?Sm9uYXMgQnVzaA==?=

    ItemDataBound not always firing:

    =?Utf-8?B?Sm9uYXMgQnVzaA==?=, Jan 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    570
    =?Utf-8?B?Sm9uYXMgQnVzaA==?=
    Jan 20, 2004
  8. Joel Zinn

    ItemDataBound error: does not contain a definition for

    Joel Zinn, Sep 14, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    1,202
    Joel Zinn
    Sep 14, 2006
Loading...