How to make a template field(textbox) as a part of the datatable
I have a GridView .
its data source is a data table
i create it pro-grammatically in .cs
to suit what i wanna to show. Now i wanna more column in this gridview as a template field containing开发者_运维技巧 a text box.(as a part of my data table). How to do this .Please if there is a sample or example this will be great.
Following tutorial will help you. This is on ASP.net 2.0 but there will not be a much different on latest versions.
http://msdn.microsoft.com/en-us/library/bb288032.aspx
Added Few other resources based on new comment
- http://www.highoncoding.com/Articles/29_Creating_Datagrid_columns_programmatically.aspx
- http://www.codeproject.com/KB/aspnet/create_template_columns.aspx?df=100&forumid=281019&exp=0&select=1726624
TemplateField bfield = new TemplateField();
bfield.HeaderTemplate = new GridViewTemplate(ListItemType.Header, col.ColumnName);
bfield.ItemTemplate = new GridViewTemplate(ListItemType.Item, col.ColumnName);
GrdView1.Columns.Add(bfield);
<asp:TemplateField HeaderText="MyTextField">
<ItemTemplate>
<asp:TextBox runat="server" id="txtField">
</ItemTemplate>
</asp:TemplateField>
More details here: http://msdn.microsoft.com/en-us/library/aa479353.aspx
However, I think you're looking to do more than just this - but I can't be certain....
精彩评论