How to create a two line header for ASP.NET GridView

My data is such that I want to display values ​​for Employee and Supervisor for a specific record. Instead of describing it, I'll show you an example:

<table><tr>
<th colspan="3">Employee</th>
<th colspan="3">Supervisor</th>
</tr><tr>
<th>Name</th>
<th>Last Activity</th>
<th>Count</th>
<th>Name</th>
<th>Last Activity</th>
<th>Count</th>
</tr>
</table>

      

How can I create this for the GridView? I essentially want 2 rows for headers, and some of the cells need to contain more than one column.

0


source to share


3 answers


Do you need editing or sorting functionality for your gridview? I found trying to do anything other than displaying live tabular data in a gridview is an exercise in patience.

For simplicity, I would recommend using a relay and write your own HTML table if your grid is read-only.

Editing to answer the comment below.



This may be the route we take, but for peer education purposes I am wondering if you can do this with a GridView. - DLarsen

You can, but it's by no means easy. If you haven't already and you can afford to switch, you can take a look at ASP.NET MVC, this will give you complete control over the HTML. You can check this link about data access in general. http://www.asp.net/learn/data-access/ # 15, # 27, # 51-53 may give you some ideas related to your gridview problem.

0


source


As Galwegian writes, data grid freezing can be achieved using CSS expressions. But this only works on IE7 and below.

For versions above IE 7 and other browsers like Firefox, the screenshot below should work.



function setWidth () {
    document.getElemenById("myDiv").style.left = body.clientWidth / 2 - oDiv.offsetWidth / 2;
    document.getElemenById("myDiv").style.top = document.body.clientHeight / 2 - oDiv.offsetHeight / 2;
}

      

See http://techbookshelf.blogspot.in/2012/09/expressions-in-css.html for details .

0


source


Perhaps to handle RowDataBound and RowType for Header, you set your own RenderMethod and write the HTML yourself.

e.Row.SetRenderMethodDelegate(New RenderMethod(AddressOf RenderHeader))

      

0


source







All Articles