bettyjennings
New Member
I'd like to programmatically add template columns to a datagrid. So instead of inserting this<BR> <asp:templatecolumn HeaderText="Mon" ><BR> <template name=ItemTemplate><BR> <asp:TextBox id=Day1 runat="server" <BR> Text='<%# DataBinder.Eval(Container, "DataItem.Monday") %>'<BR> Width="40px"/><BR> </asp:TextBox><BR> </template><BR> </asp:templatecolumn><BR><BR>I would like to do something like this<BR> for (int i = 1; i <= 7; i++) <BR> {<BR> TemplateColumn col = new TemplateColumn();<BR> col.HeaderText = "Day " + i.ToString();<BR> TextBox tb = new TextBox();<BR> tb.Text = "<%# DataBinder.Eval(Container, 'DataItem.Monday') %>";<BR> tb.Width = 30;<BR> TemplateBuilder t = new TemplateBuilder();<BR> //?????? t.Initialize(tb);<BR> //?????? col.ItemTemplate = t;<BR> DataGrid1.Columns.AddAt(i-1+4, col);<BR> }<BR><BR><BR>Any suggestions how to achieve this?<BR>