views:

4378

answers:

1

Good day,

I have a parent gridview with a few columns. On each row, I want to have a nested gridview. However, I have problems about displaying correctly the nested gridview.

If I place the nested gridview in the first columns of the parent gridview, when I will set the visible attribute to true to the nested one, of course, all the columns of the parent gridview will be moved to the right (to make some space for the child gridview).

How can I make that child gridview to span over the columns of the parent gridview? If it's not possible, how to can I achieve something similar. Of course, I don't want to place the child gridview in the last columns of the parent gridview...

Thank you very much!

Edit: We must use asp.net 2.0

+2  A: 

This is going to be somewhat tricky with the grid view control. You'll need to handle an event on the grid and then update the HTML colspan attribute on the containing column where you are adding the grid in it's control tree (not recommended).

A better choice would be to use the ListView control if you can use the 3.5 Framework. This control gives you total control of the markup. With this control you can easily specify the column span of the parent column and even make it conditional based on an inline expression (<%# Eval(condition) %>).

If the 3.5 Framework is not an option. I would attempt a solution that uses a repeater control for at least the parent table so that you have declarative control over the markup of the table layout.

I hope this helps.

James