2016-01-06 79 views

回答

1
//declare a datatable 
    DataTable dt = new DataTable(); 
    dt.Columns.Add(new DataColumn("id", typeof(int))); 
    dt.Columns.Add(new DataColumn("Name", typeof(string))); 

    //fill it with data 
    DataRow dr = dt.NewRow(); 
    dr["id"] = 1; 
    dr["Name"] = "Name" 
    dt.Rows.Add(dr); 

    //set the datasource and bind the grid view 
    GridView1.DataSource = dt; 
    GridView1.DataBind();