DataGrid If you use pagination, the last page may not be "full page" so that the layout of the DataGrid may be problematic, the remaining rows are too wide, and the entire DataGrid becomes ugly.
The solution can probably be considered from three places:
1. Fill in the new data line in the DataSource.
2, fill in the DataGrid with the new blank control row.
3. Fill in the new HTML control line with JavaScript in webpage.
I used the second method, in the response method of the PreRender event of the DataGrid, to fill in a blank line above the footer line, as follows:
protected virtual void Spidersurfgrid_prerender (object sender, System.EventArgs e)
{
DataGridItem Dgi;
System.Web.UI.WebControls.TableCell TableCell;
System.Web.UI.WebControls.TableRow TableRow;
DataGrid Grid = (sender as DataGrid);
if (grid. Controls.Count = = 0) return;
System.Web.UI.WebControls.Table Table = (grid. Controls[0] as System.Web.UI.WebControls.Table);
TableRow = (System.Web.UI.WebControls.TableRow) (table. CONTROLS[1]);
for (int j=this. Pagesize+4-table. controls.count;j>0;j--)
{
DGI = new DataGridItem (0,0,listitemtype.item);
for (int i=0;i<tablerow. controls.count;i++)
{
TableCell = new System.Web.UI.WebControls.TableCell ();
Dgi. Cells.add (TableCell);
}
Table. Controls.addat (table. CONTROLS.COUNT-2,DGI);
}
}
Description: Consider here is a header/footer/pager row, pager in the next, bound DataGrid.
The strange thing is, can not be here to add cssstyle to a row, once I dgi.cssstyle= "Dumptablerowclass", these new lines will collapse, a successful friend please enlighten me, thank you.
ATHOSSMTH Original, reprint please specify.