我有自定义类,其中有 10 个属性。我只需要在网格视图中将其中的五个显示为列。到目前为止,我已经尝试过这个:
gridView1.DataSource = reservation; // This is a List of ReservationDomain (Custom Class with the properties I want to populate in the gridview)
gridView1.DataBind();
gridView1.Columns[2].Visible = false; // At this point of time the Columns count is ZERO, so an exception is thrown.
有什么办法。我搜索了所有可以找到相同方法或通过 LINQ 的地方,它在内部也在做同样的事情。