Question

Is it possible to use a TemplateField (or any *Field from a GridView) inside a user control (ascx).

I have a complex TemplateField (item, edit, footer) that I would like to easily reuse.

Thanks.

Was it helpful?

Solution

As the question is worded, there is no way. What it sounds like you are doing (making the elements of a TemplateColumn reusable) then there are two ways that come to mind right off.

One, put your User Control into the ItemTemplate/FooterTemlate of the TemplateColumn.

Two, build the complex GridView Column as a standalone server control, which you can use in place of a TemplateColumn (or BoundColumn).

OTHER TIPS

GridView is a bit top-heavy for a user control - you could create a custom GridView in a separate control library and simply reuse it that way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top