asp GridView自己创建表头
程序员文章站
2022-05-12 20:19:39
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
&n...
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType== DataControlRowType.Header)
{
TableCellCollection Tcl = e.Row.Cells;
Tcl.Clear();
Tcl.Add(new TableHeaderCell());
Tcl[0].RowSpan = 1;
Tcl[0].Text = "编号";
Tcl.Add(new TableHeaderCell());
Tcl[1].RowSpan = 1;
Tcl[1].Text = "产品";
Tcl.Add(new TableHeaderCell());
Tcl[2].ColumnSpan = 2;//表示战2个Column,2个列合并成一个列,并叫辣椒
Tcl[2].RowSpan = 1;//表示占一行
Tcl[2].Text = "辣椒";
Tcl.Add(new TableHeaderCell());
Tcl[3].ColumnSpan = 2;
Tcl[3].RowSpan = 1;
Tcl[3].Text = "苹果";
}
摘自 Bychentufeiyang的专栏
{
if (e.Row.RowType== DataControlRowType.Header)
{
TableCellCollection Tcl = e.Row.Cells;
Tcl.Clear();
Tcl.Add(new TableHeaderCell());
Tcl[0].RowSpan = 1;
Tcl[0].Text = "编号";
Tcl.Add(new TableHeaderCell());
Tcl[1].RowSpan = 1;
Tcl[1].Text = "产品";
Tcl.Add(new TableHeaderCell());
Tcl[2].ColumnSpan = 2;//表示战2个Column,2个列合并成一个列,并叫辣椒
Tcl[2].RowSpan = 1;//表示占一行
Tcl[2].Text = "辣椒";
Tcl.Add(new TableHeaderCell());
Tcl[3].ColumnSpan = 2;
Tcl[3].RowSpan = 1;
Tcl[3].Text = "苹果";
}
摘自 Bychentufeiyang的专栏
上一篇: 网站SEO优化必要做好的七点
下一篇: SEO中网站内容怎么伪原创?