100分,请问怎么取GridView 表头值
如题.序号 姓名 成绩
1 张三 80
2 李四 90
在GridView GridView1_RowDataBound事件里
请问怎么能取到第二列表头"姓名" 这个值 --------------------编程问答-------------------- this.GridView1.Columns[1].HeaderText --------------------编程问答-------------------- if (e.Row.RowType == DataControlRowType.Header)
{
string aa = e.Row.Cells[1].Text;
} --------------------编程问答--------------------
正解。 --------------------编程问答-------------------- 1楼的哥哥给出答案了。 --------------------编程问答-------------------- 1楼正解.不过在GridView1_RowDataBound要这个内容做什么? --------------------编程问答--------------------
顶 --------------------编程问答-------------------- 一楼答案出来了。。。 --------------------编程问答-------------------- if (e.Row.RowType == DataControlRowType.Header)
{
string aa = this.GridView1.Columns[1].HeaderText;
}
这样就可以了。 --------------------编程问答-------------------- 见高分 --------------------编程问答--------------------
如果没有设置表头的名字(数据绑定的话),在GridView GridView1_RowDataBound事件里还是这个好点。 --------------------编程问答-------------------- protected void GridView_RowCreated(object sender, GridViewRowEventArgs e)
{
if ( e.Row.RowType == DataControlRowType.Header)
{
string head0 = GridView1.Columns[0].HeaderText
foreach (TableCell cell in e.Row.Cells)
{
string sFieldName = cell.Text.Trim();
}
}
}
--------------------编程问答--------------------
这方法就可以了!顶 --------------------编程问答-------------------- --------------------编程问答-------------------- 路过,学习一下.... --------------------编程问答-------------------- if (e.Row.RowType == DataControlRowType.Header)
{
string aa = e.Row.Cells[1].Text;
} --------------------编程问答-------------------- 学习中。 --------------------编程问答-------------------- 楼主可以结贴了 --------------------编程问答-------------------- --------------------编程问答--------------------
这方法就可以了!顶 --------------------编程问答-------------------- 一楼就行了 --------------------编程问答--------------------
同上 --------------------编程问答-------------------- 正解。
同上 --------------------编程问答-------------------- 同上~~~ --------------------编程问答-------------------- 这人总是很强!! --------------------编程问答-------------------- --------------------编程问答--------------------
支持这个
补充:.NET技术 , ASP.NET