views:

625

answers:

2

Is there a way to create a collapsible ASP.NET gridview displaying a parent child relationship based on a check box click?

+1  A: 

I don't think that any of the Microsoft grids can do that. However, third party grids will do this. We used ComponentArt's grid control on my last project, and used it to do exactly what you want.

Cylon Cat
Thanks for the quick response. Its' hard for me to belive there is no way to collapse child rows in a gridview through some type of javascript. Possibly even adding a + or - I've seen this somewhere? Side note how much was ComponentArt's grid?
xxmrlnxx
ComponentArt's WebUI package is 999 US dollars. That includes a lot of stuff besides the grid - menus, AJAX enhancements, much more. As I remember, their trial version is unlimited time, but it pops up an ad in place of your control about every fifth page load.I've seen people embed GridViews inside grid cells of an outer GridView, but it's pretty painful to program. The GridView isn't great for JavaScript enhancements, either. I think that MS deliberately leaves the market open for third-party vendors to offer lots of enhancements.
Cylon Cat
+1  A: 

An easy solution would be to wrap your GridView in an UpdatePanel, and just code everything as you would with normal postbacks. But this is a very heavy-handed approach.

Another option is to use Microsoft's AJAX Library to invoke PageMethods. See the second example here: http://www.asp.net/ajax/documentation/live/Tutorials/ExposingWebServicesToAJAXTutorial.aspx . Once the page loads, you can bind a function to the checkboxes' click events that invokes a PageMethod to inject the appropriate HTML labels and inputs into the row, with a link that passes the values from the form to a different PageMethod.

gWiz