Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Link Button will not fire

Reply
Thread Tools

Link Button will not fire

 
 
Bazza Formez
Guest
Posts: n/a
 
      11-16-2006
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
================================================== ====

 
Reply With Quote
 
 
 
 
Bazza Formez
Guest
Posts: n/a
 
      11-16-2006

Bazza Formez wrote:

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



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


 
Reply With Quote
 
 
 
 
Bazza Formez
Guest
Posts: n/a
 
      11-16-2006
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
> ================================================== ====


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Button.Click event doesn't fire when clicking button in formView.InsertItemTemplate Andy B. ASP .Net 0 11-25-2009 03:27 PM
Re: UpdatePanel and ASP:Button - Button's Click event doesn't fire Nathan Sokalski ASP .Net 0 01-15-2009 10:00 PM
UpdatePanel and ASP:Button - Button's Click event doesn't fire MU ASP .Net 0 01-15-2009 09:45 PM
How to fire both event button click and textchanged when button is click and text is changed Amy ASP .Net 0 06-01-2006 02:33 PM
Fire Link Button Event!!! Adam Knight ASP .Net 2 08-04-2005 11:59 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57