I asked this question regarding the strange behavior of the GridView control in ASP.Net (I use C #).
For each row in my GridView there is a “Change” and “Delete” link. Editing, for example, has this javascript:__doPostBack('gvwServers','Edit$0'). Therefore, it is obvious that the server is about to find out if someone clicked to edit the line 0 gvwServers.
Fair enough. If I click the "Edit" link, I get a postback, and the GridView will be redrawn with the "Edit" button replaced with the "Update" and "Cancel" button. Standard behavior. NOW - The Cancel button has this link javascript:__doPostBack('gvwServers','Cancel$0')- exactly what I expect Cancel line 0from gvwServers. BUT the Refresh button has javascript:__doPostBack('gvwServers$ctl02$ctl00',''). That doesn't seem to make any sense. And this, apparently, is the reason that my program processes the update without being fired.
Why doesn't ASP output the correct feedback 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>
source
share