Event handling for Nested GridView

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TimVtoo
    New Member
    • Jul 2008
    • 22

    Event handling for Nested GridView

    I'm using ASP VB.net and have a GridView inside a DataList EditItemTemplat e. I want to be able to select/edit items in the nested gridview.

    The GridView is correctly showing child records, but when I click the Edit button I get:
    The GridView 'gvStagePayment s' fired event RowEditing which wasn't handled
    I have know idia how to create this handler??


    Is this possible... I have found some examples (I think) but for c# but struggle to make any sence of it, could somebody please point me in the right direction in vb.net

    Thanks

    Tim
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Go to your VB.NET code for the page.
    Notice the 2 dropDownLists/combo boxes at the top of the code...select the GridView in the first one, and the select the Edit Event in the second.

    This will automatically generate the method that that handles the edit event for the GridView.

    If you cannot find the GridView in the DropDownList then you will have to write it by hand:

    Code:
     
      Private Sub gvStagePayments_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvStagePayments.RowEditing
    
        End Sub

    You also may have to tell the GridView to call that method when editing:
    Code:
    <asp:GridView ID="gvStagePayments" runat="server" 
    OnRowEditing="gvStagePayments_RowEditing"
    ........ >

    Comment

    • TimVtoo
      New Member
      • Jul 2008
      • 22

      #3
      Thanks Frinny, when I first read your reply I thought you must have not read my post properly and missed the fact the my gridV was nested.

      I tried manually writing the Sub as you sugested and got the following error:
      BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.


      So I removed the Handles clause and manually set OnRowEditing=". .. (as you sugested) and it works. :) I thought there was going to have to be some complicated trickery to get this working. Your a lifesaver.

      Thanks again!!

      Tim

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Awesome :)
        I knew one of the techniques would work I just didn't know which one.
        Thanks for sharing the solution!

        -Frinny

        Comment

        Working...