Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > How can I dynamically add a control to a DataGrid Template column?

Reply
Thread Tools

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

 
 
Richard
Guest
Posts: n/a
 
      08-06-2004
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
 
Reply With Quote
 
 
 
 
Rick Spiewak
Guest
Posts: n/a
 
      08-07-2004
Take a look at the ITemplate interface definition, it should show you the
way.

"Richard" <> wrote in message
news: om...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to dynamically add control to datagrid item template =?Utf-8?B?Q2hyaXMgRmluaw==?= ASP .Net 1 08-21-2007 04:04 AM
I can't dynamically add items to a DataGrid/DataList/Repeater in C#. mmumme@gmail.com ASP .Net Web Controls 0 09-02-2005 04:46 AM
How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event. Daniel Roth ASP .Net Datagrid Control 0 04-05-2005 03:58 AM
how to add checkbox in DataGrid control dynamically? J Gopinath ASP .Net Web Controls 0 06-01-2004 09:45 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57