我有一个 GridView 。
它的数据源是data table
我以编程方式创建它.cs
以适应我想要展示的内容。现在我想在这个 gridview 中添加更多列作为包含文本框的模板字段。(作为我的数据表的一部分)。如何做到这一点。如果有样本或示例,这将是很棒的。
我有一个 GridView 。
它的数据源是data table
我以编程方式创建它.cs
以适应我想要展示的内容。现在我想在这个 gridview 中添加更多列作为包含文本框的模板字段。(作为我的数据表的一部分)。如何做到这一点。如果有样本或示例,这将是很棒的。
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
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....