Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my design :
Column Name / Header Id = textbox1

Column Text / Header Text = textbox2

Column size = textbox3

i have a gridview, how to add new column using templatefield header = input from textbox1, templatefield id= input from textbox1, and template field width = input from textbox 3.

this is my code aspx :
XML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
       ShowFooter="True" CellPadding="4" ForeColor="#333333"
       Width="732px" Height="16px" AllowSorting="True"
           PageSize="20" AllowPaging="True">
           <Columns>
            <asp:TemplateField HeaderText="Report Id" Visible="False">
                                  <ItemTemplate>
                                         <asp:Label ID="lblreport_id" Width = "20px" runat="server" ForeColor="Black"
                                             Text='<%# Eval("report_id") %>'></asp:Label>
                                     </ItemTemplate>
                                     <FooterTemplate>
                               <asp:TextBox ID="txtreport_id"  Width = "20px" runat="server"></asp:TextBox>
                                      </FooterTemplate>
                                       <ControlStyle Width="20px" />
                                       <HeaderStyle ForeColor="White" />
                                          <ItemStyle Width="20px" />
                                 </asp:TemplateField>

your answer is very helpful, thanks :)
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900