I have a requirement where I would not know the columns and any result set information at design-time, so I'd be generating the data-display control dynamically.
What is the most suitable way to display this type of information on-the-fly in a table/grid like 开发者_运维问答structure on an ASP.NET page considering the following parameters (in order of importance):
- Performance
- Extensibility
- Usability
I know I can dynamically generate a gridview/repeater/listview control but what I'd like to understand is which option (from stated ones or any other beyond these) would be an optimal solution.
P.S. Paging and Sorting are part of desired functionalities, but can be overlooked if the solution is overwhelming. :)
Thanks for the help!
I think the performance depends a lot on the data provider: paging and sorting (and filtering) the data are easily the most expensive tasks when dealing with databases - so picking a renderer (GridView/listview/repeater) is more dependent on your comfort with that particular control.
In terms of extensibility options - Repeater is obviously the least "heavy" - but you're definitely committing to maintaining a glob of code that loops over and wraps your data and transforms it into "columns" (manually writing elements?) in your repeaterItems. GridView seems to give better row AND column support.
Usability: I'd really investigate some of the more modern techniques of allowing sorting/paging on grids that use AJAX - it is definitely made easier by ASP.NET AJAX or yes, I'm going to say it, jQuery. The basic concept of what I'm suggesting is: serve up the data via web methods (ScriptService attribute) to a Javascript that will render the table on the browser and handle paging/sorting requests (AJAX calls back to the ScriptService). It is more responsive and generally allows richer UIs than the built-in controls. Check out jQGrid.
Columns and rows with sorting and paging: If you wanna include adding, deleting, selecting, and editing with that I'll go with gridview.
精彩评论