Template Columns

G

Guest

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 names of them 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
each TemplateColumn.
 
S

S. Justin Gengo

Gordon,

If you leave the datagrid's AutoGenerateColumns property set to true it will
automatically generate it's columns based on every column found in the table
it's bound to. Any other column's you add manually will also be shown. So
just add the column for your textbox and set the grid to autogenerate and
you should be all set.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top