<asp:BoundColumn DataField="u_name" HeaderText="名称"></asp:BoundColumn>

解决方案 »

  1.   

    //STEP 1: Create a DataTable style object and set properties if required.
    DataGridTableStyle ts1 = new DataGridTableStyle();//specify the table from dataset (required step)
    ts1.MappingName =BW_Table;
          
    // Set other properties (optional step)
    ts1.AlternatingBackColor = Color.LightBlue;//STEP 2: Create a string column and add it to the tablestyle
    DataGridColumnStyle TextColCURDATE = new DataGridTextBoxColumn();
    TextColCURDATE.MappingName = "CURDATE"; //from dataset table
    TextColCURDATE.HeaderText = "日期";
    TextColCURDATE.Width = 100;
    ts1.GridColumnStyles.Add(TextColCURDATE);//STEP 3: Add the tablestyle to your datagrid tablestlye collection
    this.dgdBW.TableStyles.Add(ts1);
      

  2.   

    上面的程序是我用在winForm中的
      

  3.   

    DataSet ds=new DataSet();
    ....
    ds.Tables["表1"].Columns["字段1"].ColumnName="你要的名字";
    ....
    datagrid1.DataSource=ds.Tables["表1"];
      

  4.   

    //STEP 1: Create a DataTable style object and set properties if required.
    DataGridTableStyle ts1 = new DataGridTableStyle();//specify the table from dataset (required step)
    ts1.MappingName =BW_Table;
          
    // Set other properties (optional step)
    ts1.AlternatingBackColor = Color.LightBlue;//STEP 2: Create a string column and add it to the tablestyle
    DataGridColumnStyle TextColCURDATE = new DataGridTextBoxColumn();
    TextColCURDATE.MappingName = "CURDATE"; //from dataset table
    TextColCURDATE.HeaderText = "日期";
    TextColCURDATE.Width = 100;
    ts1.GridColumnStyles.Add(TextColCURDATE);//STEP 3: Add the tablestyle to your datagrid tablestlye collection
    this.dgdBW.TableStyles.Add(ts1);
     godblessyU(自由港) 是正确的方法
      

  5.   

    在写SQL语句时给字段起一个中文别名就行,如:
    string sSQL = "select name as 姓名,address as 地址 from user";
    然后直接绑定就行了,对DataGrid不用作设置
    dgrd.DataSource = ds.Table[0].DefaultView;
    dgrd.DataBind();