Anyname Donotcare
Anyname Donotcare

Reputation: 11393

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.

Upvotes: 0

Views: 2138

Answers (3)

Peter Bromberg
Peter Bromberg

Reputation: 1496

TemplateField bfield = new TemplateField();

bfield.HeaderTemplate = new GridViewTemplate(ListItemType.Header, col.ColumnName);

bfield.ItemTemplate = new GridViewTemplate(ListItemType.Item, col.ColumnName);

GrdView1.Columns.Add(bfield);

Upvotes: 1

Damith
Damith

Reputation: 63065

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

  1. http://www.highoncoding.com/Articles/29_Creating_Datagrid_columns_programmatically.aspx
  2. http://www.codeproject.com/KB/aspnet/create_template_columns.aspx?df=100&forumid=281019&exp=0&select=1726624

Upvotes: 1

FiveTools
FiveTools

Reputation: 6030

 <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....

Upvotes: 0

Related Questions