Link Button will not fire

B

Bazza Formez

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
======================================================
 
B

Bazza Formez

Bazza Formez wrote:

Just to correct something .. datagrid is called "dgUsers" (not
"dg_Users" as I wrote above).
 
B

Bazza Formez

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,061
Latest member
KetonaraKeto

Latest Threads

Top