Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 21, 2012 07:01 AM by Qin Dian Tang - MSFT
Jun 19, 2012 02:16 PM|LINK
I have a search results grid.
Now the grid binds with a list of Model class.
A new requirement arrived ie. The user can select fields which he would like to display in the grid view.
A solution in my mind is that, generate an inline query to accommodate the custom fields and then use a datatable to bind grid.
Am I in the right direction? or do we have a solution with a list of model class itself?
Thanks in advance,
Binoj K N
Jun 21, 2012 07:01 AM|LINK
Yes, you can generate any datasource with any data or column field in it. The point is to let GridView know which field you need to show. Of course, you can set AutoGenerateColumns="true" in GridView to let GridView displays columns according to the datasource
automatically. Another way is you can create dynamic GridView columns manually, then you can set the bind field manually according to the datasource: