Note that there are some explanatory texts on larger screens.

plurals
  1. POIndex was out of range in grid row command
    text
    copied!<p>I'd like to reach gridView a cell's value.But it gives the error is 'Index was out of range. Must be non-negative and less than the size of the collection. grid row command'</p> <p>Can somebody help me?</p> <pre><code> &lt;asp:GridView ID="grdList" runat="server" AutoGenerateColumns="False" GridLines="None" PageSize="5" AllowPaging="True" OnPageIndexChanging="Grd_Allergys_PageIndexChanging" OnRowCommand="grdList_RowCommand" OnRowDeleting="grdList_RowDeleting" OnRowEditing="grdList_RowEditing"&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="LangId" HeaderText="LangId" /&gt; &lt;asp:BoundField DataField="LangName" HeaderText="LangName" /&gt; &lt;asp:TemplateField HeaderText="Edit"&gt; &lt;ItemTemplate&gt; &lt;asp:ImageButton ID="imgBtnEdit" runat="server" CommandName="Edit" CommandArgument='&lt;%#Eval("LangId") %&gt;' ImageUrl="~/Image/edit.jpg" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText="Delete"&gt; &lt;ItemTemplate&gt; &lt;asp:ImageButton ID="imgBtnDelete" runat="server" CommandName="Delete" CommandArgument='&lt;%#Eval("LangId")%&gt;' ImageUrl="~/Image/delete_icon.gif" OnClientClick="return confirm('Do you want to continue ?')" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;PagerSettings Mode="Numeric" /&gt; &lt;/asp:GridView&gt; protected void grdList_RowCommand(object sender, GridViewCommandEventArgs e) { DBDataContext dc = new DBDataContext(); if (e.CommandName == "Edit") { int rowIndex = int.Parse(e.CommandArgument.ToString()); string LangName = grdList.DataKeys[rowIndex]["LangName"].ToString(); } } </code></pre>
 

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