Received the above, the DataGrid was rewritten into a header fixed, and the scroll bar rolled record. Look at the Felix brother's article fixed header scrollable datagridhttp://blog.joy.com/felix/Articles/32789.aspx seems It is a bit less suitable for yourself. He cut HEADER, made a div, then cover the original DataGrid header, forming a description, just like the head is really fixed, and the position of the two seems to be Quasi, newly-generated header is a bit left (I don't know if I have a problem with my machine). Later, according to my contest, because DataGrid finally output a table, so split this table into three, header, Items, Pager. Then add a DIV outside Items, control the height of this divitter with JavaScript to decide whether Scroll Bar. Btw: Because DataGrid we have reproduced. Some code is only suitable for this Grid, but Wan variable leave wherein enjoy it ///
// Only the following contents of the following contents if (! Griddesignmode) {// convert HTML to StringBuilder StringWriter SW = New StringWriter ();
HTMLTextWriter HTW = New HtmlTextWriter (SW);
/ / Ensure the width of each column Style ["Table-Layout"] = "Fixed";
// Output to SW. Base.Render (HTW);
Stringbuilder sbrenderedtable = sw.getstringbuilder ();
HTW.CLOSE ();
SW.CLOSE ();
String Temp = sbrenderedtable.toString ();
IF (SBRENDEREDTABLE.LENGTH> 0) {if (this.Headertext == String.empty) {// Replace DataGrid ID with Header ID SBRENDEREDTABLE.REPLACE (ID, ID "_Headers ", 0, (Temp.indexof (ID) ID.LENGTH)); / / To keep the head and the height of the table, remove the height attribute. SbrenderedTable.remove (sbrendedtable.tostring (). TOLOWER (). Indexof ("Height:"), THIS .Height.tostring (). Length 8); temp = sbrenderedTable.toString (); // to find out the length of the header. In order to split Int start = Temp.tolower (). Indexof (@ "<"); int End = Temp.tolower (). INDEXOF (@ ">") 1;
String strablestyle = Temp.substring (start, end-start); // Because you want to divide the DataGrid into three tables, use a large DIV to secure their width. And ensure that Scroll Bar does not appear. // To ensure Scroll Bar No, use overflow-y: hidden is enough if (this.height.tostring () == String.empty || this.height.tostring () == "100%) {sbrenderedTable.insert (0, @ "
StrtablesTyle = start (this.id "_ headers", ID "_Items");
// Remove the head with the content. Add a div to the content to display scroll bar sbrenderedtable.insert ((Temp.tolower ()). Indexof (@ "<<<< TR>") 5, @ / Table> " @"
Int IntheightIndex = strablepager.tolower (). INDEXOF ("Height:");
IF (INTHEIGHTINDEX> 0) {strablepager = strappager.remove (Intheight ", this.height.tostring (). Length 8);}
// Disconnect the content with the pagination. SbrenderedTable.Insert (sbrenderedtable.tostring (). TOLOWER (). Indexof (@ "
// Use Javascript to match the width of the column and the column contents header StringBuilder adjustStyleScript = new StringBuilder ();. AdjustStyleScript.Append (@ "