GridView控件HeaderRow.TableSection错误 [英] GridView HeaderRow.TableSection error
本文介绍了GridView控件HeaderRow.TableSection错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
GridView的HeaderRow.TableSection设置为TableRowSection.TableHeader时,我有一个坏的错误:该表必须包含标题,正文的定单行部分,然后页脚。
请注意,我这样做是在电网DataBound事件处理程序,我不使用分页。这怎么可能呢?
I have a bad error when setting GridViews HeaderRow.TableSection to TableRowSection.TableHeader: The table must contain row sections in order of header, body, then footer. Please, note, that I do it in grids DataBound event handler and I do NOT use paging. How can it be?
感谢您,
推荐答案
首先,你应该设置在第一行的类型时,它会创建的标题:
First you should set type of the first row to header when it will created :
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex == 0)
{
e.Row.RowType = DataControlRowType.Header;
}
}
现在你可以这样做:
GridView1.DataSource = dt;
GridView1.DataBind();
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
这篇关于GridView控件HeaderRow.TableSection错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文