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 7032303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:55:03+00:00 2026-05-28T00:55:03+00:00

Im having trouble with my update command. It finds the textbox controls but it

  • 0

Im having trouble with my update command. It finds the textbox controls but it doesn’t get the new values entered into it and i can’t figure out why. i’ve done some tutorials and im not getting far. In my Update event is a class called Pages which updates the text and that works if i add the text values manually. The problem is accessing the newly updated text from my textboxes.

    <asp:GridView ID="CustomGridView1" runat="server" AutoGenerateColumns="false" DataKeyNames="Name" AutoGenerateSelectButton="true"
    ShowHeaderWhenEmpty="True" ShowFooter="true" AutoGenerateEditButton="true" OnDataBound="CustomGridView_DataBound"
    OnRowEditing="CustomGridView_CancelEditCommand" OnRowCommand="CustomGridView1_RowCommand" 
    OnLoad="CustomGridView1_Load" OnRowUpdated="CustomGridView1_RowUpdated" OnRowUpdating="CustomGridView1_RowUpdating" OnRowCancelingEdit="CustomGridView1_RowCancelingEdit"
     ShowHeader="true">
            <Columns>
        <asp:TemplateField HeaderText="Page Name" HeaderStyle-HorizontalAlign="Left">
            <ItemTemplate>
                <%# Eval("Name") %>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="Name" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Path" HeaderStyle-HorizontalAlign="Left">
            <ItemTemplate>
                <%# Eval("Path") %>
            </ItemTemplate>
            <EditItemTemplate>                    
                <asp:TextBox ID="Path" runat="server" Text='<%# Bind("Path") %>'></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Route Value" HeaderStyle-HorizontalAlign="Left">
            <ItemTemplate>
                <%# Eval("RouteValue") %>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="RouteValue" runat="server" Text='<%# Bind("RouteValue") %>'></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="RegExp" HeaderStyle-HorizontalAlign="Left">
            <ItemTemplate>
                <%# Eval("RegExp") %>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="RegExp" runat="server" Text='<%# Bind("RegExp") %>'></asp:TextBox>
            </EditItemTemplate>
        </asp:TemplateField>
    </Columns>        
</asp:GridView>

This part here isn’t firing i prefere the method RowUpdated Method in the answer is there a reason why my Updated Event is not firing

protected void CustomGridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
    if (e.Exception == null && e.AffectedRows == 1)
    {
        Pages pages = new Pages();
        SystemPage SySPage = new SystemPage();
        SySPage.Name = e.NewValues[0].ToString();
        SySPage.Path = e.NewValues[1].ToString();
        SySPage.RouteValue = e.NewValues[2].ToString();
        SySPage.RegExp = e.NewValues[3].ToString();
        pages.Update(SySPage, xmlFile);

        CustomGridView1.EditIndex = -1;
        BindData();
    }

}

protected void CustomGridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

    for (int i = 0; i < CustomGridView1.Columns.Count - 1; i++)
    {
        DataControlFieldCell cell = CustomGridView1.Rows[CustomGridView1.EditIndex].Cells[i] as DataControlFieldCell;
        CustomGridView1.Columns[i].ExtractValuesFromCell(e.Keys, cell, DataControlRowState.Edit, false);
    }

    Pages pages = new Pages();
    SystemPage SysPage = new SystemPage();
    SysPage.Name = e.NewValues[0].ToString();
    SysPage.Path = e.NewValues[1].ToString();
    SysPage.RouteValue = e.NewValues[2].ToString();
    SysPage.RegExp = e.NewValues[3].ToString();
    pages.Update(SysPage, xmlFile);

    lblInsert.Text = e.NewValues[3].ToString();

    CustomGridView1.EditIndex = -1;
    BindData();
}
  • 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-28T00:55:04+00:00Added an answer on May 28, 2026 at 12:55 am

    To get the values AFTER updating you should handle the GridViews RowUpdated Event http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowupdated.aspx not the RowUpdating.

    <asp:GridView OnRowUpdated="GridViewUpdatedEventHandler" />
    

    Edit
    The updated fields in the GridView are exposed by a property, NewValues, in the GridViewUpdatedEventArgs which is exposed as a parameter of the RowUpdated event.

    Code as requested I cannot test this code as I am not near a dev pc.
    Add the following method to your code file and set the GridViews OnRowUpdated property to point to the method.

    protected void CustomGridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
        {
            if ((e.Exception == null) && (e.AffectedRows == 1))
            {
                Pages pages = new Pages();
                SystemPage SysPage = new SystemPage();
                SysPage.Name = e.NewValues[0].ToString();
                SysPage.Path = e.NewValues[1].ToString();
                SysPage.RouteValue = e.NewValues[2].ToString(); ;
                SysPage.RegExp = e.NewValues[3].ToString(); ;
                pages.Update(SysPage, xmlFile);
    
                CustomGridView1.EditIndex = -1;
                BindData();
            }
            else
                // TO DO: ALERT the user the update errored
    
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble dynamically adding controls inside an update panel with partial postbacks. I've
I'm having trouble trying to update my xml file with a new value. I
I've got an admin section setup, but am having trouble getting the update route
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
I'm new to iPhone development and I'm having trouble using the 3rd part Kal
Im having trouble with a stored procedure, I can't commit after I execute it.
I am having trouble with the following command prompt commands (in Windows XP). set
I'm having trouble with my tablesorter and ajax div content update. Once the ajax
i am having trouble getting this to work, can any one spot the issue?
I'm having trouble getting an INSERT query to execute properly, and I can't seem

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.