表tableDefinition中放置了表中字段的定义,有以下的结构和记录:
tablename, fieldname, fieldCaption, ...
student     name        姓名
student     age         年龄
student     score       成绩另有表student包含上述字段对student表的查询操作由stu类的select()方法提供请问:如何自动把呈现student表内容的gridView列的HeaderText更改为tableDefinition表中对应的fieldCaption字段值?

解决方案 »

  1.   

    比较古怪的要求,去看看msdn把
      

  2.   


    .aspx 文件中.
    HeaderText = <%# fieldCaption %>
    --------------------------------------------------------------------------------
    析软网
    http://www.parsesoft.net
    http://bbs.parsesoft.net
    致力于 DocBook 的应用,专注于开源软件的解析、手册/指南、以及应用文章、书籍的发布。
      

  3.   

    gridView.Columns[i].HeaderText = xxx
      

  4.   


    又想了一下,好像这样不行。
    --------------------------------------------------------------------------------
    析软网
    http://www.parsesoft.net
    http://bbs.parsesoft.net
    致力于 DocBook 的应用,专注于开源软件的解析、手册/指南、以及应用文章、书籍的发布。
      

  5.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if ((e.Row.RowType == DataControlRowType.Header))
            {
                foreach (TableCell cell in e.Row.Cells)
                {
                    string sFieldName = cell.Text.Trim();
                    DataTable dt = "select * from 表 where tablename='student'";//查询                DataRow[] rows  = dt.Select("fieldname='" + sFieldName + "'");
                    if (rows.Length > 0)
                    {
                        cell.Text = rows[0]["fieldCaption"].ToString();
                    }
                }
            }
            
            
        }
      

  6.   

    做个循环遍历tableDefinition的fieldCaption字段,给GridView1的每列的HeaderText赋值
    GridView.Columns[i].HeaderText = ...
      

  7.   

    select name as 用户名,ageas 年龄  from ………… 这样不就可以了吗?