Sharing: Using PreRender to troubleshoot the final page row number of DataGrid page layout problem

Source: Internet
Author: User
Tags count final
datagrid| Page | solve | The problem
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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.