RowCommand Event of a nested Gridview

N

NEO

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.
 
B

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
ASP.NET.

Brennan Stehling
http://brennan.offwhite.net/blog/
 

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

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top