Note that there are some explanatory texts on larger screens.

plurals
  1. POHow does FindControl work in GridView?
    primarykey
    data
    text
    <p>I am trying to update a database using the GridView edit, update CommandField. I have two editable fields which are displayed as text boxes when in edit mode. When clicking submit, I am trying to put the text box values into variables to work with, but I am unable to access them. The two column names are "EOR" and "CategoryName". I have found several suggestions on other forums to try something like:</p> <pre><code>protected void ResultGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtEor = (TextBox)myGridName.Rows[e.RowIndex].FindControl("EOR"); </code></pre> <p>When I debug the program, txtEor is always null. The only thing i can think of is that I am not referencing the cell properly. I set the Headertext, AccessibleHeaderText, DataField, and SortExpression to "EOR" but it still just comes up null.</p> <p>Any help would be greatly appreciated!</p> <p>asp for the gridview:</p> <pre><code>&lt;asp:GridView ID="grdEOR" runat="server" BackColor="White" BorderColor="#999999" OnPageIndexChanging="grdEor_PageIndexChanging" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical" AllowPaging="True" PageSize="15" AutoGenerateColumns="False" onrowediting="grdEOR_RowEditing" onrowcancelingedit="grdEOR_RowCancelingEdit" onrowupdating="grdEOR_RowUpdating" onrowdeleting="grdEOR_RowDeleting" ShowFooter="True"&gt; &lt;PagerSettings Mode="NumericFirstLast" /&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="EORCategoryID" HeaderText="EORCategoryID" SortExpression="EORCategoryID" ReadOnly="True"&gt; &lt;/asp:BoundField&gt; &lt;asp:BoundField DataField="EOR" HeaderText="EOR" SortExpression="EOR" AccessibleHeaderText="EOR"/&gt; &lt;asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" /&gt; &lt;asp:CommandField ButtonType="Button" ShowDeleteButton="True" ShowEditButton="True" /&gt; &lt;/Columns&gt; &lt;FooterStyle BackColor="#CCCCCC" /&gt; &lt;PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /&gt; &lt;SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" /&gt; &lt;HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /&gt; &lt;AlternatingRowStyle BackColor="#CCCCCC" BorderColor="Black" BorderStyle="Solid" BorderWidth="5px" /&gt; &lt;/asp:GridView&gt; </code></pre>
    singulars
    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.
 

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