动态每一行后重复标题行 [英] Repeat header row after each row dynamically
本文介绍了动态每一行后重复标题行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何能重复标题行的GridView的每一行之后?
How can I repeat the header row after each row of gridview?
推荐答案
您可以添加code到您的网格的RowDataBound事件:
You might add code to the rowdatabound-event of your grid:
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridViewRow row = new GridViewRow(e.Row.RowIndex, 0, DataControlRowType.Header, DataControlRowState.Normal);
TableCell cell = new TableCell();
cell.Controls.Add(new Label { Text = "Header" }); //as needed
row.Cells.Add(cell);
Table tbl = (e.Row.Parent as Table);
tbl.Controls.AddAt(e.Row.RowIndex * 2 + 1, row);
}
}
在这个例子中,我已经完全为你写你自己的code背后取下GridView的标题。
In this example, I have removed the gridview header altogether as you write your own in code behind.
这篇关于动态每一行后重复标题行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文