.net DataGrid绑定列手动添加数据

前台DataGrid:

 

                    Font-Bold="False" OnItemCommand="Data_ItemCommand" OnItemDataBound="Data_ItemDataBound"
            PageSize="5" Width="100%">
           
                   
                   
                   
           

       

 

后台cs:

 

        DataTable dt = new DataTable();
       
        dt.Columns.Add("aaa");
        dt.Columns.Add("bbb");
        dt.Columns.Add("ccc");

        dt.Rows.Clear();
        DataRow dr = dt.NewRow();

        dr[0] = "aaaaa";
        dr[1] = "bbbbb";
        dr[2] = "ccccc";

        dt.Rows.InsertAt(dr,0);
        axDgdData.DataSource = dt;
        axDgdData.DataBind();

        int i = dt.Columns.Count;
        Response.Write(i.ToString());

 

转载于:https://www.cnblogs.com/Godblessyou/archive/2010/08/09/1795550.html

你可能感兴趣的:(.net DataGrid绑定列手动添加数据)