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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:37:14+00:00 2026-05-19T17:37:14+00:00

I asked this question regarding a strange behaviour from a GridView control in ASP.Net

  • 0

I asked this question regarding a strange behaviour from a GridView control in ASP.Net (I’m using C#).

For each row in my GridView there is an an ‘Edit’ and ‘Delete’ link. The edit for example has this javascript:__doPostBack('gvwServers','Edit$0') – So obviously the server is going to figure out someone has clicked to edit row 0 of gvwServers.

Fair enough. If I click the Edit link I get a postback and the GridView is redrawn with the Edit button replaced with an ‘Update’ and ‘Cancel’ button. Standard behaviour. NOW – The ‘Cancel’ button has this link javascript:__doPostBack('gvwServers','Cancel$0') – just what I would expect Cancel row 0 of gvwServers. BUT The Update button has javascript:__doPostBack('gvwServers$ctl02$ctl00',''). This appears to not make any sense. And this appears to be the cause of my routine to handle Update not being fired.

Why is ASP not outputting the correct postback arguments?

My code is available at the link above.

<asp:GridView ID="gvwServers" runat="server" class="gvwServers"  
AutoGenerateColumns="false"  OnRowEditing="gvwServers_Edit" 
onrowcancelingedit="gvwServers_Cancelling" onrowdeleting="gvwServers_Deleting" 
onrowupdated="gvwServers_Updated" onrowupdating="gvwServers_Updating"
AutoGenerateEditButton=true AutoGenerateDeleteButton=true>

<columns>
    <asp:CommandField  ShowEditButton="true" />
    <asp:CommandField  ShowDeleteButton="true" /> 
    <asp:BoundField DataField="intServerID" visible="false" />

    <asp:TemplateField HeaderText = "Server Name">
        <ItemTemplate>
            <asp:Label ID="lblServerName" runat="server" Text='<%# Bind("txtName") %>'></asp:Label>
        </ItemTemplate>
        <EditItemTemplate>
            <asp:TextBox ID="txtServerName_Edit" runat="server" Text='<%# Bind("txtName") %>'></asp:TextBox>
        </EditItemTemplate>
    </asp:TemplateField>

    <asp:TemplateField  HeaderText = "Key">
        <ItemTemplate>
            <asp:Label ID="lblAppKey" runat="server" Text='<%# Bind("txtApplicationKey") %>'></asp:Label>
        </ItemTemplate>
        <EditItemTemplate>
            <asp:TextBox ID="txtAppKey_Edit" runat="server" Text='<%# Bind("txtApplicationKey") %>'></asp:TextBox>
        </EditItemTemplate>
    </asp:TemplateField>

    <asp:TemplateField  HeaderText = "Connection String">
        <ItemTemplate>
            <asp:Label ID="lblConnString" runat="server" Text='************'></asp:Label>
        </ItemTemplate>
        <EditItemTemplate>
            <asp:TextBox runat="server" ID="txtConnString_Edit" Width="300px" Height="100px" Text='<%# Bind("txtConnectionString")%>' TextMode="MultiLine" ></asp:TextBox>
        </EditItemTemplate>
    </asp:TemplateField>

</columns>
</asp:GridView> 
  • 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-19T17:37:15+00:00Added an answer on May 19, 2026 at 5:37 pm

    Not sure what you’re expecting/not happening. I took your gridview code and used your code behind in the other link. I added a Response.Write in each handler and it seems to run as expected.

    public class Item
    {
        public int intServerID { get; set; }
        public string txtName { get; set; }
        public string txtApplicationKey { get; set; }
        public string txtConnectionString { get; set; }
    }
    
    protected void Page_Load(object sender, EventArgs e)
    {
        Item item = new Item();
        item.intServerID = 1;
        item.txtName = "Apple";
        item.txtApplicationKey = "Orange";
        item.txtConnectionString = "Test";
    
        List<Item> items = new List<Item>();
        items.Add(item);
    
        gvwServers.DataSource = items;
        gvwServers.DataBind();
    }
    
    protected void gvwServers_Edit(object sender, GridViewEditEventArgs e)
    {
        Response.Write("Edit");
        gvwServers.EditIndex = e.NewEditIndex;
        gvwServers.DataBind();
    }
    protected void gvwServers_Updated(object sender, GridViewUpdatedEventArgs e)
    {
        Response.Write("Updated");
        gvwServers.DataBind();
    }
    
    protected void gvwServers_Updating(object sender, GridViewUpdateEventArgs e)
    {
        Response.Write("Updating");
        gvwServers.DataBind();
    }
    protected void gvwServers_Deleting(object sender, GridViewDeleteEventArgs e)
    {
        Response.Write("Delete");
        gvwServers.DataBind();
    }
    protected void gvwServers_Cancelling(object sender, GridViewCancelEditEventArgs e)
    {
        Response.Write("Cancel");
    
        e.Cancel = true;
        gvwServers.EditIndex = -1;
        gvwServers.DataBind();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I originally asked this question on RefactorMyCode , but got no responses there... Basically
Yesterday, I asked this question regarding best practices for a simple information retrieval system
Previously I asked this question: Read quicktime movie from servlet in a webpage? Basically
(I asked this question in another way , and got some interesting responses but
I asked this question before, Here however I think I presented the problem poorly,
I asked this question a while back but now I'm looking to implement an
I asked this question: Serial Port (rs232) in Mono for multiple platforms and this
I've asked this question to the forums on the Mootools website and one person
I was asked this question in a job interview. The interviewer and I disagreed
I was asked this question during an interview. They're both O(nlogn) and yet most

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.