当前位置:编程学习 > C#/ASP.NET >>

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 楼 guao 的回复:
this.GridView1.Columns[1].HeaderText

正解。 --------------------编程问答-------------------- 1楼的哥哥给出答案了。 --------------------编程问答-------------------- 1楼正解.不过在GridView1_RowDataBound要这个内容做什么? --------------------编程问答--------------------
引用 1 楼 guao 的回复:
this.GridView1.Columns[1].HeaderText



顶 --------------------编程问答-------------------- 一楼答案出来了。。。 --------------------编程问答-------------------- if (e.Row.RowType == DataControlRowType.Header)
  {
  string aa = this.GridView1.Columns[1].HeaderText;
  }
这样就可以了。 --------------------编程问答-------------------- 见高分 --------------------编程问答--------------------
引用 2 楼 shiyuyao1987 的回复:
 if (e.Row.RowType == DataControlRowType.Header)
        {
            string aa = e.Row.Cells[1].Text;
        }

如果没有设置表头的名字(数据绑定的话),在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();
    }                                 
  }  
  }  
--------------------编程问答--------------------
引用 1 楼 guao 的回复:
this.GridView1.Columns[1].HeaderText


这方法就可以了!顶 --------------------编程问答--------------------
引用 1 楼 guao 的回复:
this.GridView1.Columns[1].HeaderText
--------------------编程问答-------------------- 路过,学习一下.... --------------------编程问答-------------------- if (e.Row.RowType == DataControlRowType.Header)
  {
  string aa = e.Row.Cells[1].Text;
  } --------------------编程问答-------------------- 学习中。  --------------------编程问答-------------------- 楼主可以结贴了 --------------------编程问答--------------------
引用 12 楼 yusheng622 的回复:
引用 1 楼 guao 的回复:

this.GridView1.Columns[1].HeaderText


这方法就可以了!顶
--------------------编程问答--------------------
引用 1 楼 guao 的回复:
this.GridView1.Columns[1].HeaderText


这方法就可以了!顶 --------------------编程问答-------------------- 一楼就行了 --------------------编程问答--------------------
引用 3 楼 lingrain 的回复:
引用 1 楼 guao 的回复:
this.GridView1.Columns[1].HeaderText

正解。

同上 --------------------编程问答--------------------
引用 21 楼 zmcici 的回复:
引用 3 楼 lingrain 的回复:
引用 1 楼 guao 的回复:
this.GridView1.Columns[1].HeaderText

正解。

同上
正解。

同上 --------------------编程问答-------------------- 同上~~~ --------------------编程问答--------------------
引用 11 楼 wuyq11 的回复:
protected void GridView_RowCreated(object sender, GridViewRowEventArgs e)  
  {  
  if ( e.Row.RowType == DataControlRowType.Header)  
  {  
  string head0 = GridView1.Columns[0].HeaderText
  for……
这人总是很强!! --------------------编程问答-------------------- --------------------编程问答--------------------
引用 10 楼 z415353144 的回复:
引用 2 楼 shiyuyao1987 的回复:

if (e.Row.RowType == DataControlRowType.Header)
{
string aa = e.Row.Cells[1].Text;
}

如果没有设置表头的名字(数据绑定的话),在GridView GridView1_RowDataBound事件里还是这个好点。


支持这个
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,