开发者

How to hide columns GridView when AutoGenerateColumns = "true"?

I am using an Asp:GridView with AutoGenerateColumns property set to true to display all the fields. But I am struck with a problem here. I need to show only few columns not all..but I do not know them until run-time, like which fields to bind.

So, There are 2 sets of columns coming for me one with Prefix B_ and the other with Prefix R_ I need to show开发者_StackOverflow社区 either B_ or R_ based on the radio button selection.

But I do not want to make separate call to the DB on radio button selection, So I am pulling all the data at once, when I am binding to the grid.

But the problem as I said it is showing all the columns but initially I want the grid to display only columns with prefix B_

Is there a way can I achieve this, Please do help me..

Thanks and appreciate your feedback.


I'd recommend loading them into two different sets of objects, and changing the value of the ItemsSource DataSource property when different radio button values are selected.

EDIT: Replaced ItemsSource with DataSource, getting my ASP.NET and WPF mixed up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜