Dynamically create TemplateColumn

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there, I cannot write a datagrid on the aspx because i do not know the
names of the column headings until i run a query. So i have to do it
programatically from the datasource.

I have managed to add a couple of boundcolumns based on my datasource easy
peasy but can't find any help anywhere to show me how to dynamically set up
the itemtemplate within a templatecolumn (and add say a checkbox to it). So
what goes after this? I know the syntax is wrong in the following but I cant
find anything close to this in the properties or methods of templatecolumn.
I read another post saying 'new columnTemplate' but cant find this class
anywhere..

TemplateColumn tc = new TemplateColumn();
//want to do the following
ItemTemplate it = new ItemTemplate()
it.Controls.Add(a Checkbox)
tc.Controls.Add(it)
 
Thanks for that. very helpful. however i havent worked out from that how to
add controls such as a checkbox to the itemtemplate. Theres no control
collection or add method anywhere ??
 
Back
Top