我想把Sring[]绑定到GridView上,问题是:DataField怎么设置?因为string[]没有字段名

解决方案 »

  1.   

    字段名设置成为!(感叹号)
    更多资料:http://www.34v.com
      

  2.   

    直接后台DataSource=
    不设字段名
      

  3.   

    GridView有一个事件:RowDataBound
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if(((Label)e.Row.FindControl("FlagLabel"))!=null)
            {
                Label adlabel = (Label)e.Row.FindControl("FlagLabel");
                if(adlabel.Text =="1")
                    adlabel.Text = "管理ユーザ";
                if (adlabel.Text == "0")
                    adlabel.Text = "普通ユーザ";
            }
        }这是我项目里面的代码,粘贴给你,希望能够帮助你!
      

  4.   

    DataTable dt = new DataTable();
    dt.Columns.Add(new DataColumn("id"));
    string[] str = {"1","2","3"};
    for (int i = 0; i < 3; i++)
    {
        DataRow dr = dt.NewRow();
        dr["id"] = str[i];
        dt.Rows.Add(dr);
    }