Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Header On TemplateField In GridView

How to create Header "Full Name" in GridView when I am creating "TemplateField" with hyperlinks ? For example I want these rows in TemplateField to have header "Full Name".

<asp:GridView ID="CustomersGridView" runat="server" AutoGenerateColumns="False" >
        <Columns>

            <asp:TemplateField>
                <ItemTemplate>
                <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("FirstName") + " " + Eval("LastName")  %>'
                     NavigateUrl="CarTest.aspx" > </asp:HyperLink>        
                </ItemTemplate>
            </asp:TemplateField>

        </Columns>
</asp:GridView>
like image 396
TheChampp Avatar asked Jan 31 '13 19:01

TheChampp


2 Answers

Use the header template:

 <Columns>
    <asp:TemplateField>
          <ItemTemplate>
               ....................
          </ItemTemplate>
          <HeaderTemplate>
                Full Name
         </HeaderTemplate>
     </asp:TemplateField>
  </Columns>

For more information, read.

like image 79
Marcus Vinicius Avatar answered Sep 23 '22 14:09

Marcus Vinicius


<asp:GridView ID="CustomersGridView" runat="server" AutoGenerateColumns="False" >
    <Columns>

        <asp:TemplateField HeaderText="Full Name">
            <ItemTemplate>
            <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("FirstName") + " " + Eval("LastName")  %>'
                 NavigateUrl="CarTest.aspx" > </asp:HyperLink>        
            </ItemTemplate>
        </asp:TemplateField>

    </Columns>
</asp:GridView>
like image 38
Kiran1016 Avatar answered Sep 23 '22 14:09

Kiran1016