Take the effect of setting through CSS in the previous article and copying it to a window similar to excel (fix the above and left-side table headers)
This time, I want to apply the same effect to ASP. NET. However, if you have encountered several problems in the middle, you need to exclude them one by one. Remember the following method:
1. first, this method is not the standard CSS coding method. However, when a webform is opened, aspx will add a line to check whether it is in the standard format, this line will cause loss, and this line must be deleted
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2. In the HTML generated by the gridview, a div is automatically added, which causes this. parentelement. offsetparent. parentelement. scrollleft In the CSS.
Take the token and modify it
This. parentelement. offsetparent. offsetparent. scrollleft
For example:
First, add CSS settings to the same table.
.FixedTitleRow { position: relative; table-layout:fixed; top: expression(this.offsetParent.scrollTop-2); background-color:White; z-index: 10; } .FixedTitleRow th{ text-overflow:ellipsis; overflow:hidden; white-space: nowrap; padding:2px;} .FixedTitleColumn { position: relative; left: expression(this.parentElement.offsetParent.scrollLeft-2); } .FixedDataColumn { position: relative; left: expression(this.parentElement.offsetParent.offsetParent.scrollLeft-2); }
Then add the aspx upload case and remember to remove it.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
The content of the gridview is as follows:
<Div style = "width: 600px; Height: 400px; overflow: Scroll; Z-index: 100;"> <asp: gridview id = "gridview1" runat = "server" autogeneratecolumns = "false" datakeynames = "orderid" performanceid = "sqlperformance1" emptydatatext = "No information is displayed. "Cellpadding =" 4 "forecolor =" #333333 "gridlines =" NONE "> <rowstyle backcolor =" # e3eaeb "/> <columns> <asp: boundfield datafield = "orderid" headertext = "orderid" readonly = "true" sortexpression = "orderid">
The result is as follows:
Easy to use
- Set cssclass = fixedtitlecolumn of headstyle and cssclass = fixeddatacolumn of itemstyle in the left-side data row.
- Set cssclass = fixedtitlerow for the headstyle of the entire gridview.
This is done !!