0
我有數據集,你可以看到below.I想隱藏前三列。但我下面的做法是行不通的。我怎樣才能隱藏它們?gridview隱藏後數據綁定列或之前
// Read all posts and fill gridview
//////////////////////////////////////////////////
DbCommand dbCommand2;
dbCommand2 = db.GetStoredProcCommand("PC_Select_News");
db.AddInParameter(dbCommand2, "UserId", DbType.Guid, new Guid(Session["SessionUserId"].ToString().Trim()));
DataSet ds = db.ExecuteDataSet(dbCommand2);
grid_all_posts.DataSource = ds;
grid_all_posts.DataBind();
grid_all_posts.Columns[1].Visible = false;
grid_all_posts.Columns[2].Visible = false;
http://stackoverflow.com/questions/3819247/gridview-hide-column-by-code – Joe 2013-02-11 15:33:22
它不工作。 – 2013-02-11 15:37:03
我解決了它。你應該使用下面的代碼和aspx文件,你應該把ondatabound事件處理程序在gridview – 2013-02-11 15:48:53