Datagrid e.Item.Cells(1) argument was out of range

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Datagrid e.Item.Cells(1) argument was out of range

    I'm creating a dynamic datagrid using Dim objbc As New BoundColumn, etc. The
    datagrid is populating correctly. I am also using first column of grid as
    'edit', on clicking this the update link is displayed and textboxes are
    returned. All good so far.

    When I change the values in the text box and click update, I keep getting:
    Specified argument was out of the range of valid values. Parameter name: index

    for this line
    tb = CType(e.Item.Cells(1).Controls(0), TextBox)

    I've checked the content of e.item.cells and it is empty, why????

    If I create the datagrid and bind it directly to a dataset then everything
    works, however I want to create the dataset, etc. completely dynamically.
    What am I missing? I've seen much correspondence of others getting the same
    issue, but there are no answers. After much searching I did find a post
    suggesting that the issue is due to viewstate, and that the binding of the
    columns should be done on Page_Init and not Page_Load. Is this the solution
    I'm looking for?
    Del Guest

  2. Similar Questions and Discussions

    1. Simple question: e.Item.Cells(0).Controls*(0)
      I am new at this.. probably not proficient enough to even consider myself a Newbie yet. :-) I have a DataGrid with Template columns. After the...
    2. Can't get text of e.Item.Cells(x)
      Hi, I cannot grab the text of a datagrid row's cell. I am trying to access the value in the datagrid's ItemCreated event. I use a conditional...
    3. e.Item.Cells[] doesn't get the content of the cell i clicked in(sorry this is the full message.
      e.item.cells only gets you to the cell, you then need to access the control in the cell and look at the control's text, not the cell's text. It...
    4. CType(e.Item.Cells(3).Controls(1), textbox) fails when key is set to READONLY
      The code could not be simpler: Dim txtProjectID As TextBox = CType(e.Item.Cells(1).Controls(0), TextBox) Dim dblProjectID As Double =...
    5. Blank value returned on ItemDataBound event using e.Item.Cells
      Hi, I have a datagrid and want to be able to assess the value of one cell on each line in order to hide or display the hyperlink in the next...
  3. #2

    Default RE: Datagrid e.Item.Cells(1) argument was out of range

    Please ignore my question, a colleague has assisted me in solving the
    problem. The issue lay around the way I was getting the data and binding it
    to the grid.


    "Del" wrote:
    > I'm creating a dynamic datagrid using Dim objbc As New BoundColumn, etc. The
    > datagrid is populating correctly. I am also using first column of grid as
    > 'edit', on clicking this the update link is displayed and textboxes are
    > returned. All good so far.
    >
    > When I change the values in the text box and click update, I keep getting:
    > Specified argument was out of the range of valid values. Parameter name: index
    >
    > for this line
    > tb = CType(e.Item.Cells(1).Controls(0), TextBox)
    >
    > I've checked the content of e.item.cells and it is empty, why????
    >
    > If I create the datagrid and bind it directly to a dataset then everything
    > works, however I want to create the dataset, etc. completely dynamically.
    > What am I missing? I've seen much correspondence of others getting the same
    > issue, but there are no answers. After much searching I did find a post
    > suggesting that the issue is due to viewstate, and that the binding of the
    > columns should be done on Page_Init and not Page_Load. Is this the solution
    > I'm looking for?
    Del Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139