Groups | Blog | Home
all groups > asp.net datagrid control > september 2005 >

asp.net datagrid control : Create ItemTemplates at runtime


Gordon
9/15/2005 4:49:02 AM
Hi,

Fairly new to ASP.net. I want to create a Datagrid that will bind to a
DataSet created a runtime and which will hence have a variable number of
columns. I want to show the data in binded textboxes.
I can't create template columns in the designer because I don't know the
number and column name but I can see how to do it at runtime ie in Page_Init
for (int counter=0;counter<dataSet1.Columns.count; counter++) {
TemplateColumn dc = new TemplateColumn()
dc.HeadText = dataset1.Columns[counter].ColumnName
DataGrid1.Columns.Add(dc)
}

but I'm a bit lost on how to add an ItemTemplate which has a bound textbox
to each TemplateColumn as I create them



--
Regards

msnews.microsoft.com
9/18/2005 9:56:00 AM

[quoted text, click to view]

Hi Gordon,

I have a sample that adds checkboxes and dropdownlists to a customized
template at runtime.
http://www.societopia.net/Samples/DataGridEventDelegates.aspx

The process of adding a textbox is not different.

HTH,
Phillip Williams
http://www.webswapp.com
http://www.societopia.net


AddThis Social Bookmark Button