ASP.NET - Hierarchical Grid View

Any ideas on how I can achieve a "hierarchical" gridview? Basically what I want is when the user clicks on the "+" it "expands" and inserts new lines without the full page message.

Does this sound like a lot of AJAX stuff? Or should I read on ASP.NET MVC

Please point me in the right direction

+1


source to share


4 answers


Another way to do this is with the old Grid view inside Trick. The basic idea is to have [+] and parent data as element data in the same column template. Attach a button click event and set a grid for edit / select mode. when in edit mode, displays a second grid view with child data. Although this is a gridview within a gridview, visually it will perform a "hierarchical" view.



+1


source


Source code for a Hierarchical GridView  with [-] and [+] to collapse and expand like in VB6 hierarchical grid



+1


source


You have two options:

  • You can show the lines you want to insert and [+] shows them and hides them.
  • You don't render them and they are sent to the browser via AJAX and then inserted into the table.

I've done it both ways, and yet the more general way to do it is the first one in my opinion. You can create a new template field for [+]; determine the name of the child relation and then call GetChildRows (or equivalent) on each row when rendering, if those rows are being rendered.

0


source


@bnkdev - GridView inside GridView sounds like a complete mess.

@Jandwenyi - I suppose you are doing this in a specific scenario and you will need to reuse it at some point, as badly as possible as it might seem right now. My suggestion is to find a third party grid control that will do what you want - there are so many out there.

0


source







All Articles