Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

.NET

Hi experts!

how can i add a textbox control to a template column in a web server data grid control at run time ?

Cryogenic Buragohain (INDIA)
Friday, June 11, 2004

Hi, outsourcing destination!

Go screw yourself.


Friday, June 11, 2004

Real helpful.

You would just need to get a reference to the TemplateColumn's Controls collection and use the Add method to dynamically create a new one.

Add(new System.Web.UI.WebControls.TextBox())

but better to create a new TextBox before doing the Add call so that you can set some properties.

Not having worked with DataGrids generally and TemplateColumn's specifically, I can't address the first part of the solution. Figure out how to programmatically access a specific TemplateColumn on a specific DataGrid and you're 90% there.

Bill Brown
Friday, June 11, 2004

This is for Bill Brown's response:

i add the template column using the code below

TemplateColumn tcol = new TemplateColumn();
DataGrid1.Columns.Add(tcol);

but the problem is how can i make that tcol as the container of other activex control!!

Cryogenic
Tuesday, June 15, 2004

How about:
tcol.Controls.Add( childControl );

Duncan Smart
Thursday, June 17, 2004

By the way - it's not ActiveX... how very 1997

Duncan Smart
Thursday, June 17, 2004

*  Recent Topics

*  Fog Creek Home