How can I dynamically add a control to a DataGrid Template column?

R

Richard

I want to do the following:

// create the template column ...
TemplateColumn tc = new TemplateColumn();
tc.HeaderText = "Location";
tc.HeaderStyle.Width = Unit.Percentage(40);

// create a label for the item template ...
label = new Label();
label.ID = "lbl" + Tree + "Location";
label.Text = "<%# DataBinder.Eval(Container.DataItem, 'Location') %>";

// Add the label to the template column
??? The unlike the dataGrid.Columns, the template column has no
Add method so how do I add the control ???

dataGrid.Columns.Add(tc);


The area where the ??? are is where I need help. Any help would be appreciated.

Thanks
 
R

Rick Spiewak

Take a look at the ITemplate interface definition, it should show you the
way.
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top