Note that there are some explanatory texts on larger screens.

plurals
  1. POButton does not submit on first click, but on subsequent click submits previous information
    text
    copied!<p>I am making an editable <code>GridView</code>, but my problem is that whenever I click on a button nothing happens. When I click a second time I see what happened during the previous click. </p> <h3>aspx</h3> <pre><code> &lt;%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" EnableEventValidation="true" CodeBehind="Default.aspx.cs" Inherits="BeheerSysteemWeb._Default" %&gt; &lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt; &lt;h2&gt; &lt;asp:GridView ID="GridView1" runat="server" onrowcancelingedit="GridView1_RowCancelingEdit" onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating" AutoGenerateColumns="False"&gt; &lt;Columns&gt; &lt;asp:CommandField ButtonType="Button" ShowEditButton="true" ShowCancelButton="true" /&gt; &lt;asp:TemplateField HeaderText="36"&gt; &lt;EditItemTemplate&gt; &lt;asp:TextBox runat="server" ID="txtSpoor" Text="TramNummer" /&gt; &lt;/EditItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/h2&gt; &lt;/asp:Content&gt; </code></pre> <h3>Codebehind</h3> <pre><code> namespace BeheerSysteemWeb { public partial class _Default : System.Web.UI.Page { List&lt;string&gt; leeg = new List&lt;string&gt;(); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { LoadData(); } } private void LoadData() { leeg.Add(""); leeg.Add(""); leeg.Add(""); leeg.Add(""); GridView1.DataSource = leeg; GridView1.DataBind(); } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; } protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { e.Cancel = true; GridView1.EditIndex = -1; } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridView1.Rows[e.RowIndex]; TextBox txtSpoor = (TextBox)row.FindControl("txtSpoor"); e.Cancel = true; GridView1.EditIndex = -1; } } } </code></pre> <p>How can I get the button to work in ASP.NET ?</p>
 

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