GridView 的 Footer 如何跨欄置中
2009-02-10 10:04 LvSir 阅读(490) 评论(0) 收藏 举报GridView 的 Footer 如何跨欄置中
原來要這樣寫,如果你是在IDE就把 GridView 就產生好,並把 Column 都設定完成。可是在頁面呈現時,在footer 那會出現格線,也就是說,如果有五個 Column ,在footer 那也會有五個 cell ,那看來很奇怪。
所以下面這一段code 就可以用上啦 ^^
所以下面這一段code 就可以用上啦 ^^
protected void gvDelv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].ColumnSpan = e.Row.Cells.Count;
e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;
for (int i = e.Row.Cells.Count; i > 1; i--)
{
e.Row.Cells.RemoveAt(i - 1);
}
}
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].ColumnSpan = e.Row.Cells.Count;
e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;
for (int i = e.Row.Cells.Count; i > 1; i--)
{
e.Row.Cells.RemoveAt(i - 1);
}
}
为了实现梦想,无论遇到多么大的困难,都不退缩!