Results 1 to 6 of 6

Thread: ASP Net - GridView1_RowCommand Event is not fired

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    5

    ASP Net - GridView1_RowCommand Event is not fired

    Hi,
    I am using C# for my coding and I have create a web application in the given hierarchy:

    1. There is a Master Page: UserMaster.Master
    2. ContentPlaceHolder: UserContentPlaceHolder
    3. I am using this master page in my web form.
    4. I am using a gridview in this web form. Following is the gridview:

    <asp:GridView ID="grdRequestLicence"runat="server"AutoGenerateCo lumns="False" OnRowCommand="grdRequestLicence_RowCommand" >
    <Columns>
    <asp:BoundField DataField="STATUS_ID" HeaderText="Status ID"/>
    <asp:TemplateField HeaderText="Action">
    <ItemTemplate>
    <asp:Button ID="btnGet_Key" runat="server" Text="Get Key"/>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>

    5.I am using grdRequestLicence_RowCommand for row commands.
    protected void grdRequestLicence_RowCommand(object sender, GridViewRowEventArgs e)

    The grid is easily populated but when I am trying to click on button in grid, no event is fired.

    Somebody please help me find out the trap...

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: ASP Net - GridView1_RowCommand Event is not fired

    Moved to ASP.NET.

  3. #3
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: ASP Net - GridView1_RowCommand Event is not fired

    Did your page tag has the
    vb Code:
    1. AutoEventWireup="true"
    ?
    Please mark you thread resolved using the Thread Tools as shown

  4. #4
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: ASP Net - GridView1_RowCommand Event is not fired

    Quote Originally Posted by himanshu2s
    Hi,
    I am using C# for my coding and I have create a web application in the given hierarchy:

    1. There is a Master Page: UserMaster.Master
    2. ContentPlaceHolder: UserContentPlaceHolder
    3. I am using this master page in my web form.
    4. I am using a gridview in this web form. Following is the gridview:

    <asp:GridView ID="grdRequestLicence"runat="server"AutoGenerateCo lumns="False" OnRowCommand="grdRequestLicence_RowCommand" >
    <Columns>
    <asp:BoundField DataField="STATUS_ID" HeaderText="Status ID"/>
    <asp:TemplateField HeaderText="Action">
    <ItemTemplate>
    <asp:Button ID="btnGet_Key" runat="server" Text="Get Key"/>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>

    5.I am using grdRequestLicence_RowCommand for row commands.
    protected void grdRequestLicence_RowCommand(object sender, GridViewRowEventArgs e)

    The grid is easily populated but when I am trying to click on button in grid, no event is fired.

    Somebody please help me find out the trap...
    When dealing with .NET data objects, LinkButtons are usually the way to go, in my opinion.. just easier to deal with. Regardless, the only way you're gonna get the RowCommand event to fire is by specifying a CommandName and CommandArgument on the object calling the event, in your case, btnGet_Key.

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    5

    Re: ASP Net - GridView1_RowCommand Event is not fired

    Hi,

    Thanks all for posting the reply. I am very sorry for a late post here.

    1. AutoEventWireup property was already set to true.
    2. Somehow I managed to solve the problem. I don't know how but the EnableViewState property was set to false earlier. I removed this, I am now able fire the RowCommand Event.

    Thanks a lot for the support.

    Regards,

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: ASP Net - GridView1_RowCommand Event is not fired

    EnableViewState had been set to false on the grid or on the page? I didn't see it in the markup

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width