Multi-layer header of DataGrid under ASP.NET

xiaoxiao2021-03-06  71

First look at the following table:

Salesist area Beijing, Shanghai, China, Zhang San 100200300, China

In fact, the DataGrid under ASP.NET is just a htmltable, but only adds a lot of attributes, methods, and incorporates the ViewState mechanism on the basis of HTMLTABLE, to generate, control it; there is this understanding, things are very good. :

We can define the header of the column in the property generator, which actually only insert " " HTML tag between the columns, which is therefore, and it can be in accordance with the above example. In the HEADER in column 3, enter the following content " Beijing Shanghai Shenzhen " At this time, you will find that the 2nd floor of the head appears:

Salesist area Beijing, Shanghai, China

But it is obviously not enough, because we also need a line, the column merge

We can handle it in the DataGrid ItemDATABOUND event

IF (E.Item.ItemType == ListItemType.Header) {E.Item.cells [0] .ROWSPAN = 2; E.Item.cells [1] .Columnspan = 3; E.Item.cells [2] .visible = false; E.Item.cells [3] .visible = false;

转载请注明原文地址:https://www.9cbs.com/read-93117.html

New Post(0)