Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8976425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:07:51+00:00 2026-06-15T19:07:51+00:00

I am making an editable GridView , but my problem is that whenever I

  • 0

I am making an editable GridView, 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.

aspx

 <%@ Page Title="Home Page" Language="C#"
 MasterPageFile="~/Site.master" AutoEventWireup="true"
 EnableEventValidation="true"
     CodeBehind="Default.aspx.cs" Inherits="BeheerSysteemWeb._Default" %>

 <asp:Content ID="HeaderContent" runat="server"
 ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content
 ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
     <h2>
         <asp:GridView ID="GridView1" runat="server"
         onrowcancelingedit="GridView1_RowCancelingEdit" 
             onrowediting="GridView1_RowEditing" 
             onrowupdating="GridView1_RowUpdating" AutoGenerateColumns="False">
             <Columns>               
                 <asp:CommandField ButtonType="Button" ShowEditButton="true" ShowCancelButton="true" />              
                 <asp:TemplateField HeaderText="36">
           <EditItemTemplate>
             <asp:TextBox runat="server" ID="txtSpoor" Text="TramNummer" />
           </EditItemTemplate>
       </asp:TemplateField>
             </Columns>        
         </asp:GridView>
     </h2>
     </asp:Content>

Codebehind

 namespace BeheerSysteemWeb 
 {
     public partial class _Default : System.Web.UI.Page
     {
         List<string> leeg = new List<string>();
         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;
         }
     } 
}

How can I get the button to work in ASP.NET ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:07:52+00:00Added an answer on June 15, 2026 at 7:07 pm

    I am not sure if this is the issue here, but you need to add your data on every page call, and make DataBind after the actions as:

       public partial class _Default : System.Web.UI.Page
         {
             List<string> leeg = new List<string>();
             protected void Page_Load(object sender, EventArgs e)
             {
                 LoadData();
    
                 if (!Page.IsPostBack)
                 {
                     GridView1.DataBind();
                 }
             }
    
             private void LoadData()
             {
                 leeg.Add("");
                 leeg.Add("");
                 leeg.Add("");
                 leeg.Add("");
                 GridView1.DataSource = leeg;             
             }
    
             protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
             {
                 GridView1.EditIndex = e.NewEditIndex;
                 GridView1.DataBind();
             }
    
             protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
             {
                 e.Cancel = true;
                 GridView1.EditIndex = -1;
                 GridView1.DataBind();
             }
    
             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;
                 GridView1.DataBind();
             }
         } 
    

    Try that to see if you solve your issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to draw editable polyline that connects all points I click on
I use JEditable for making edit field which following code: $(function() { $(.field).editable(http://localhost/index.php/welcome/update_record, {
I have the simple JS code for making a simple field editable: <html> <head>
Making a new site but something is happening to it in IE8. The social
Making a new site but something is happening to it in IE. I've purchased
Making an adobe flex ui in which data that is calculated must use proprietary
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
I am making a tiny script to make a HTML element editable. When you
i'm making a notification system, so that a user in a virtual community to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.