0

I'd like to customize a GridView so that:

  • thead and tfoot are shown
  • the paging template is customized
  • it allows paging as well as sorting
  • etc...

I'd like for this settings to be retained in the entire project so that if I have 50 grid views all of them have the same characteristics.

As far as I can see I have these options:

  • custom user control (difficult to forward column templates)
  • copy and paste the aspx code and code behind code for the grid in all 50 pages

None of those are particularly great. Are there any other options? If not, how can I correctly extend GridView and forward the SelectMethod and/or custom column templates?

Shoe
  • 74,840
  • 36
  • 166
  • 272
  • Can "skin" help you? https://msdn.microsoft.com/en-us/library/aa479342.aspx I prefer to copy the code in every page (maybe in the future you'd like to customize it) – Emanuele May 08 '17 at 15:44

1 Answers1

0

Take a look at Control Adapters. They can do some of what you're asking, especially with regard to showing thead/tfoot.

I have an example in this question that uses a ControlAdapter to modify the regular DropDownList control to show OptGroups as section headings.

Aside from that, you may want to inherit from the default GridView control to create your own gridview for this project, where you have overridden the properties you want to set to always have the values you need.

Community
  • 1
  • 1
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • I haven't found much on the topic of inheriting from existing controls. Is there any documentation about that? For example, what should my custom GridView aspx page contain? – Shoe May 08 '17 at 16:03