2009年3月23日 星期一
GridView Head 跨欄
GridView 表頭 如果要有兩個 Row 以上,且要 Colspan 那就要自己動手做了,看了網路上的各家範例後,自己也實作一個簡單的,記錄下來以供日後參考!
*.cs
=============================
protected void gvList_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
GridViewRow headRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell head2Cell = new TableCell();
head2Cell.Text = "負擔與分配";
head2Cell.HorizontalAlign = HorizontalAlign.Center;
headRow.Cells.Add(head2Cell);
head2Cell = new TableCell();
head2Cell.Text = "負擔手續費";
head2Cell.ColumnSpan = 4;
head2Cell.HorizontalAlign = HorizontalAlign.Center;
headRow.Cells.Add(head2Cell);
head2Cell = new TableCell();
head2Cell.Text = "分配手續費";
head2Cell.ColumnSpan = 4;
head2Cell.HorizontalAlign = HorizontalAlign.Center;
headRow.Cells.Add(head2Cell);
gvList.Controls[0].Controls.AddAt(0,headRow);
}
}
=============================
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言