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