I've placed a gridview on an ascx. The RowDataBound fires for each row, but the RowCommand event doesn't fire at all.
In an earlier thread I saw that turning page caching off solves this problem, but I've already set the cache time to 0 in the page settings for my module and the event still doesn't fire.
Here's the html for the gridview:
<asp:GridView ID="grdAdvertisers" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton id="btnDetail" runat="server" CommandName="ShowDetail" ImageUrl="~/images/edit.gif"
CommandArgument='<%# DataBinder.Eval(Container,"DataItem.AdvertiserID")%>'>
</asp:imagebutton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="ID" DataField="AdvertiserID" />
<asp:BoundField HeaderText="Advertiser Name" DataField="AdvertiserName" />
</Columns>
</asp:GridView>
And here's the code-behind:
Private Sub grdAdvertisers_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdAdvertisers.RowDataBound
'do stuff here - works fine
End Sub
Private Sub grdAdvertisers_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grdAdvertisers.RowCommand
'we never get here because the event doesn't fire
End Sub
As mentioned earlier, RowDataBound works fine, so I'm at a loss as to why RowCommand doesn't. I'd really appreciate someone helping with this. Thanks very much in advance.