2013-10-22 35 views

回答

2

嘗試可能會解決你的問題如下:

確保gridview的(假設他ID = 「gridview1」)是標記和AutoGenerateColumns="True"

DataTable dataTable = new dataTable(); 
dataTable.Columns.Add("Column1"); 
dataTable.Columns.Add("Column2"); 
dataTable.Columns.Add("Column3"); 

DataRow dataRow = dataTable.NewRow(); 

dataRow["Column1"] = ""; 
dataRow["Column2"] = ""; 
dataRow["Column3"] = ""; 

dataTable.Rows.Add(dataRow); 

gridview1.DataSource = datatable; 
gridview1.DataBind(); 
+1

謝謝你的時間。 – dinesh

0

什麼是這樣的:

var grd = new GridView(); 
grd.AutoGenerateColumns = false; 
BoundField field = new BoundField(); 
field.DataField = "CustomerName"; 
field.HeaderText = Resources.GlobalResources.Customer; 
DataControlField col = field; 
grd.Columns.Add(col); 
grd.DataSource = sortedCustomers; 
grd.DataBind(); 
相關問題