Adding dynamic columns to an ASP.NET Gridview

前端 未结 9 1384
不思量自难忘°
不思量自难忘° 2020-12-28 18:54

I\'m having a problem dynamically adding columns to a GridView. I need to change the layout -- i.e. the included columns -- based on the value in a DropDownList. When the

9条回答
  •  死守一世寂寞
    2020-12-28 19:13

    I found this little nugget in the documentation, under the DataControlFieldCollection Class.

    If you are using the GridView or DetailsView control, the DataControlField objects that are automatically created (for example, when the AutoGenerateColumns property is true) are not stored in the publicly accessible fields collection. You can only access and manipulate DataControlField objects that are not automatically generated.

    I guess the answer is to do all of your column manipulation in code, and then your approach should work fine.

提交回复
热议问题