RowCommand Event of a nested Gridview



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.



Brennan Stehling

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