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

  • Home
  • SEARCH
  • 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 6136393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:35:52+00:00 2026-05-23T17:35:52+00:00

I am using a gridview. When I click on the edit button the update

  • 0

I am using a gridview. When I click on the edit button the update and cancel button appear.
Upon modifying the values in textbox which come from EditItemTemplate , the new values dont show in the event handler rowupdating(), instead I get the values which appear when the page was rendered. How do I grab the new values from these textboxes and proceed further?
Here is the code.

<asp:GridView ID="GridView1" runat="server" AutoGenerateEditButton="true" AutoGenerateColumns="false" 
        AutoGenerateDeleteButton="true" onrowediting="GridView1_RowEditing" 
        onrowupdating="GridView1_RowUpdating">
    <Columns>


    <asp:TemplateField>
    <ItemTemplate>
        <asp:Label ID="lblId" runat="server" Text='<%# Eval("id") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:TextBox ID="txtId" runat="server" Text='<%# Eval("id") %>'></asp:TextBox>
    </EditItemTemplate>
    </asp:TemplateField>

    <asp:TemplateField>
    <ItemTemplate>
        <asp:Label ID="lblName" runat="server" Text='<%# Eval("cpuname") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <asp:TextBox ID="txtName" runat="server" Text='<%# Eval("cpuname") %>'></asp:TextBox>
    </EditItemTemplate>
    </asp:TemplateField>

    <asp:TemplateField>
    <ItemTemplate>
        <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("status") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate> 
      <asp:TextBox ID="txtStatus" runat="server" Text='<%# Eval("status") %>'></asp:TextBox>
     </EditItemTemplate>
    </asp:TemplateField>

    </Columns>


</asp:GridView>


protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;
        }

        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            TextBox text = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName");
        }
  • 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-05-23T17:35:52+00:00Added an answer on May 23, 2026 at 5:35 pm

    You should use the two way binding here. I.e. Bind instead of Eval:

    <asp:TextBox ID="txtId" runat="server" Text='<%# Bind("id") %>'></asp:TextBox>
    

    Here is the link to documentation:

    Data-Binding Expressions Overview

    Here is my code behind:

    protected void Page_Load(object sender, EventArgs e)
        {
            DataTable table = new DataTable();
            table.Columns.Add("Data");
            for(int i = 0; i < 20; i++)
                table.Rows.Add(new object[] { i });
            GridView1.DataSource = table;
        if(!IsPostBack)  // <<<<<<<<<<<<
            GridView1.DataBind();
        }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;
            GridView1.DataBind();
        }       
    
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            TextBox text = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtId");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Gridview with Edit option. When i click on Edit button row
I have a GridView which has normal Edit/Update button. However, my GV RowUpdating, RowEditing
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Hi i m using GridView with hovermenu and i want that when we click
I am using a gridview to select, delete and update data in database. I
I have a ListView which is using a GridView to display a DataTable and
I have a GridView containing records from a table which can be deleted or
I'm currently counting all the checked checkboxes in an asp.net gridview using: $('#cphMain_gdvSalesOrder').delegate('input:checkbox', 'click',
I Have a UserControl called TenantList.ascx which contains a slightly modified GridView from DevExpress
I have a gridview which I am using to display a dataset result. The

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.