I have the answer, and I should have rembered this simple problem.
In the definition of the actual datagrid in the aspx file, I should
have added the OnItemCommand setting that specifies the function to
invoke in the code behind... in my case the function to call is
dgUsers_ItemCommand ...
ie. <asp:datagrid id="dgUsers" runat="server"
OnItemCommand="dgUsers_ItemCommand" ...............etc
Bazza Formez wrote:
> Hello,
>
> In my aspx file I have a LinkButton inside a template column, inside a
> datagrid.
> I have assigned a CommandName to the button.
>
> In my code behind, I attempt to trap the command in the ItemCooamd for
> the Datagrid.
> I have used this successfully before with no problems. This time
> however, the button will not fire ItemCommand.
>
> I can't see anything wrong after a long time looking. Note that the
> datagrid definitely has an id of dg_Users
>
> Please can someone help ?
> Thanks.
> ================================================== ==
> Here is a the aspx code for the template column inside the datagrid :
>
> asp:TemplateColumn SortExpression="Name" HeaderText="Name (click name
> to edit)"> <HeaderStyle HorizontalAlign="Left" Width="40%"
> CssClass="grid-header" VerticalAlign="Middle"></HeaderStyle>
> <ItemStyle CssClass="grid-first-item"></ItemStyle>
> <ItemTemplate><asp:LinkButton runat="server" ID="btnLinkUsers"
> Text="Edit User" CommandArgument='<%# DataBinder.Eval(Container,
> "DataItem.UserName") %>' CommandName="InvokeEditUser"></asp:LinkButton>
> </ItemTemplate>
> </asp:TemplateColumn>
> ================================================== ====
>
> Here is the code behind (which is never invoked)
>
>
> Sub dgUsers_ItemCommand(ByVal sender As Object, ByVal e As
> DataGridCommandEventArgs)
> If e.CommandName = "InvokeEditUser" Then
> Response.Redirect("ClientUserDetail.aspx?UserName= " &
> CType(e.CommandArgument, String) &
> "&index={0}&adminindex={1}&clientid=" & ClientID)
> End If
> End Sub
> ================================================== ====
|