RowCommand Event of a nested Gridview

Discussion in 'ASP .Net Web Controls' started by NEO, Oct 3, 2006.

  1. NEO

    NEO Guest

    How do I handle the RowCommand event for a nested gridview? I want to be able
    to detect which command (edit or delete) for the child gridview and the row
    that raised the event. I don't have problems with the parent gridview.
    NEO, Oct 3, 2006
    1. Advertisements

  2. I assume you are having a problem with the Design Mode to get at the
    Events listing in the Properties window. That is a problem.

    In this case what I do is handle the RowDataBound event. In there I
    can get to the Cell holding the embedded controls and set values on
    them. In your case, you want to reach into it and attach an event
    handler. You need to do it programatically since you cannot do it with
    the designer.

    Then you want to set the CommandName and CommandArgument values of your
    button controls so that when the RowCommand event is raised you can
    check those values to determine what to do.

    Using an embedded GridView within a GridView entails many caveats. You
    are going to have to be careful. And be sure to run through it a bit
    with the debugger to understand what is actually doing. What you
    expect it would do can often be something very different than what is
    actually doing. That has bitten me plenty as I have worked with

    Brennan Stehling
    Brennan Stehling, Oct 3, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.