Templated properties in composite control containing a datagrid

G

glevik

Hello,

I'm new to this. I have a composite server custom control that contains
a datagrid, and can't quite figure out an easy way to make it
configurable from an ASPX page - the same way datagrids are configured,
with columns section etc. I know ITemplate is involved, but I am not
sure how to just grab all the templated properties and have the
internal datagrid use them for configuration. Any suggestions are
highly appreciated.

Leo
 
J

John Saunders

Hello,

I'm new to this. I have a composite server custom control that contains
a datagrid, and can't quite figure out an easy way to make it
configurable from an ASPX page - the same way datagrids are configured,
with columns section etc. I know ITemplate is involved, but I am not
sure how to just grab all the templated properties and have the
internal datagrid use them for configuration. Any suggestions are
highly appreciated.

My first suggestion:
"Developing Microsoft® ASP.NET Server Controls and Components" from
Microsoft Press, by Nikhil Kothari and Vandana Datye
(http://www.microsoft.com/mspress/books/5728.asp)



Secondly, you can't directly do what you want. The fact that your composite
control contains a DataGrid is unknown to VS.NET. If you want the user to be
able to specify templates for the DataGrid, then these have to be the
templates of your control - which you'll then give to the DataGrid.



So, it looks like you need to learn how to create a templated control, which
isn't that easy. Start off with the above book, which will take you there.



John Saunders
 
G

glevik

John,

Thanks for your help. I've been able to make a templated control,
however I'm am still in the dark as to how to pass the templated
properties of the container control to the datagrid that it contains.
Any info is appreciated.

Lev
 
J

John Saunders

John,

Thanks for your help. I've been able to make a templated control,
however I'm am still in the dark as to how to pass the templated
properties of the container control to the datagrid that it contains.
Any info is appreciated.

For instance, let's say that your control is called "Container", and you
give it a template property called, ItemTemplate:

public ITemplate ItemTemplate
{
get
{
EnsureChildControls();
return _dataGrid.ItemTemplate;
}
set
{
EnsureChildControls();
_dataGrid.ItemTemplate = value;
}
}

I think that should do it, along with the proper attribute support.
TemplateContainerAttribute etc.

John Saunders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top