Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecified arguments was out of the range of valid values. Parameter name: index
    primarykey
    data
    text
    <p>This was the original line in code-behind <strong>(CType(row.Cells(0).Controls(0), TextBox))</strong> and it didn't work. After that, I changed it to <strong>row.Cells(1)</strong> and received the above error when attempting to update a field in GridView. Here're the aspx markups:</p> <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="TicketID" DataSourceID="historySqlDataSource" ForeColor="#333333" GridLines="None" Width="828px" OnRowEditing="GridView1_RowEditing" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowUpdating="GridView1_RowUpdating"&gt; &lt;AlternatingRowStyle BackColor="White" ForeColor="#284775" /&gt; &lt;Columns&gt; &lt;asp:CommandField ShowEditButton="True" /&gt; &lt;asp:BoundField DataField="TicketID" HeaderText="TicketID" InsertVisible="False" ReadOnly="True" SortExpression="TicketID" /&gt; &lt;asp:BoundField DataField="DateCreated" HeaderText="DateCreated" SortExpression="DateCreated" /&gt; &lt;asp:BoundField DataField="FullName" HeaderText="FullName" SortExpression="FullName" /&gt; &lt;asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" /&gt; &lt;asp:BoundField DataField="TicketType" HeaderText="TicketType" SortExpression="TicketType" /&gt; &lt;asp:BoundField DataField="Subject" HeaderText="Subject" SortExpression="Subject" /&gt; &lt;asp:BoundField DataField="Message" HeaderText="Message" SortExpression="Message" /&gt; &lt;asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" /&gt; &lt;/Columns&gt; &lt;EditRowStyle BackColor="#999999" /&gt; &lt;FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt; &lt;HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /&gt; &lt;PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /&gt; &lt;RowStyle BackColor="#F7F6F3" ForeColor="#333333" /&gt; &lt;SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /&gt; &lt;SortedAscendingCellStyle BackColor="#E9E7E2" /&gt; &lt;SortedAscendingHeaderStyle BackColor="#506C8C" /&gt; &lt;SortedDescendingCellStyle BackColor="#FFFDF8" /&gt; &lt;SortedDescendingHeaderStyle BackColor="#6F8DAE" /&gt; &lt;/asp:GridView&gt; </code></pre> <p>And below are the code-behind:</p> <pre><code>Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) GridView1.EditIndex = e.NewEditIndex BindData() End Sub Protected Sub GridView1_RowCancelingEdit(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs) GridView1.EditIndex = 1 BindData() End Sub Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Dim dt = CType(Session("dt"), DataTable) 'if your current DataSource be in Session Dim row As GridViewRow = GridView1.Rows(e.RowIndex) dt.Rows(row.DataItemIndex)("TicketID") = (CType(row.Cells(1).Controls(0), TextBox)).Text dt.Rows(row.DataItemIndex)("DateCreated") = (CType(row.Cells(2).Controls(0), TextBox)).Text dt.Rows(row.DataItemIndex)("FullName") = (CType(row.Cells(3).Controls(0), TextBox)).Text dt.Rows(row.DataItemIndex)("TicketType") = (CType(row.Cells(4).Controls(0), TextBox)).Text dt.Rows(row.DataItemIndex)("Subject") = (CType(row.Cells(5).Controls(0), TextBox)).Text dt.Rows(row.DataItemIndex)("Message") = (CType(row.Cells(6).Controls(0), TextBox)).Text dt.Rows(row.DataItemIndex)("Status") = (CType(row.Cells(7).Controls(0), TextBox)).Text Session("dt") = dt GridView1.EditIndex = 1 BindData() End Sub Private Sub BindData() GridView1.DataBind() End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload