I have an asp.net 4.5 web application and I'm trying to add a textbox in a gridview from C#. How can I do that? All the examples I found are about setting an ItemTemplate and adding a TextBox in it. That's not what I want.
So I have this:
<asp:GridView ID="InsertReportData" runat="server" Visible="False">
<Columns>
</Columns>
</asp:GridView>
I have managed to add boundfield and itemtemplate with this:
BoundField bfield = new BoundField();
bfield.HeaderText = "Name";
bfield.DataField = "Name";
InsertReportData.Columns.Add(bfield);
TemplateField tfield = new TemplateField();
tfield.HeaderText = "Country";
InsertReportData.Columns.Add(tfield);
How can I add a textbox in this tfield? I should be able to it with:
tfield.ItemTemplate.InstantiateIn();//but when I tried adding a textbox here, it didn't work..can't compile..error.
Can this be done somehow?