I imagine that u have a template column through which you are firing row command event.
Try to change that to the Command Column and see if it works.
I had a scenario where I was removing a row from gridview. my delete button was a template column. It did not work, but when i changed that to the deletecommand column it worked.
Let me know,
Hi Javier,
I tried it, it worked fine. Please try my sample:
<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { Label1.Text = e.CommandName + " on " + DateTime.Now.ToString(); } protected void Page_Load(object sender, EventArgs e) { }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" OnRowCommand="GridView1_RowCommand"> <Columns> <asp:CommandField ShowEditButton="True" /> <asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CommandName="MyCustomCommand">LinkButton</asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetBasicInformationOfAllEmployees" TypeName="Northwind"></asp:ObjectDataSource> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></html>Please feel free to let me know if there is any problem.
No comments:
Post a Comment