Solved

Linkbutton Inside Gridview Not Firing Server Side Code

Posted on 2009-07-15
2
479 Views
Last Modified: 2012-05-07
Please see me code below.

I've debugged and set a breakpoint on the  gvProds_RowCommand subroutine and it's not hitting it.

Any ideas?
<asp:GridView ID="gvProds" runat="server" BackColor="#EEEEEE" GridLines="horizontal" AllowSorting="false" CssClass="TextLabel" Width="780px"

AutoGenerateColumns="false" DataKeyNames="key" EnableViewState="false" >

<SelectedRowStyle BackColor="LightYellow" Font-Bold="true" />

<HeaderStyle BackColor="LightSlateGray" ForeColor="White" />

<AlternatingRowStyle BackColor="#DDDDDD" Font-Bold="false" />

<RowStyle Font-Bold="false" />                                

<Columns>                                                                        

<asp:TemplateField>

<ItemTemplate>

<asp:LinkButton ID="lnkDetails" runat="server" Text="Details." CommandArgument='<%# eval("key") %>' CommandName="select" CausesValidation="false">								  </asp:LinkButton>

</ItemTemplate>

</asp:TemplateField>

</Columns>                                                        

</asp:GridView>
 

                       
 
 
 

    Protected Sub gvProds_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvProds.RowCommand
 

        If e.CommandName = "select" Then

            Me.hdnSelectedItem.Value = CType(sender, GridView).DataKeys(e.CommandArgument).Value

            SetMenuOptions(1)

        End If
 

    End Sub

Open in new window

0
Comment
Question by:synapse88
2 Comments
 
LVL 11

Accepted Solution

by:
b_levitt earned 500 total points
ID: 24862738
you could try wiring the even in the tag:
<asp:GridView onrowcommand="gvProds_RowCommand"...

Are you binding the grid without a if(!IsPostBack) check?  If so try that or bind the grid in prerender instead.

ViewState turned off somewhere?
0
 

Author Comment

by:synapse88
ID: 24863420
It was view state, thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now