如何在 ASP.NET 中为 gridview 中的每个标题列添加标题 [英] how to add title for every header column in gridview in ASP.NET

查看:14
本文介绍了如何在 ASP.NET 中为 gridview 中的每个标题列添加标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ASP.NET,我有一个 gridview,我需要在每个标题列中放置一个标题,标题将显示在 moseover 上 ..............................我是否必须将字段转换为 TemplateField

i'm using ASP.NET , i have a gridview and i need to put a title in every header column , title will show on moseover ................................. do i have to convert the field to TemplateField

这样的事情:

 <asp:BoundField DataField="ID_Dossier" HeaderText="ID_Dossier" ReadOnly="True" 
  SortExpression="ID_Dossier" title="Trier par identifiant des dossiers " />

这是我的网格:

 <asp:GridView ID="DossierGV" runat="server" AllowPaging="True" 
                            AllowSorting="True" DataSourceID="DossierPF" AutoGenerateColumns="False" 
                            DataKeyNames="ID_Dossier">
                          <Columns>
                              <asp:TemplateField ShowHeader="False" >
                                  <ItemTemplate>
                                      <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                                          CommandName="Select" Text="Ajouter" title="Ajouter les information de finance aux ce dossier"></asp:LinkButton>
                                  </ItemTemplate>
                              </asp:TemplateField>
                              <asp:BoundField DataField="ID_Dossier" HeaderText="ID_Dossier" ReadOnly="True" 
                                  SortExpression="ID_Dossier" title="Trier par identifiant des dossiers " />
                              <asp:BoundField DataField="ID_Entreprise" HeaderText="ID_Entreprise"  
                                  SortExpression="ID_Entreprise" />
                              <asp:BoundField DataField="Date_Depot" HeaderText="Date_Depot" 
                                  SortExpression="Date_Depot"  />
                              <asp:BoundField DataField="Type_Etude" HeaderText="Type_Etude" 
                                  SortExpression="Type_Etude" />
                              <asp:BoundField DataField="Dernier_Type" HeaderText="Dernier_Type" 
                                  SortExpression="Dernier_Type"  />
                              <asp:BoundField DataField="Eligibile" HeaderText="Eligibile" 
                                  SortExpression="Eligibile" />
                              <asp:BoundField DataField="Fiche_Information" HeaderText="Fiche_Information" 
                                   />
                              <asp:BoundField DataField="Buletin_Adhesion" HeaderText="Buletin_Adhesion" 
                                   />
                              <asp:BoundField DataField="Fiche_Renseignment" HeaderText="Fiche_Renseignment" 
                                   />
                              <asp:BoundField DataField="Attestation" HeaderText="Attestation" 
                                  />
                              <asp:BoundField DataField="ID_Cabinet" HeaderText="ID_Cabinet" 
                                  SortExpression="ID_Cabinet"  />
                              <asp:BoundField DataField="Montant_Demander" HeaderText="Montant_Demander" 
                                  SortExpression="Montant_Demander" />
                              <asp:BoundField DataField="Duree" HeaderText="Duree" SortExpression="Duree" />
                              <asp:BoundField DataField="Porcentage_Taux" HeaderText="Porcentage_Taux" 
                                  SortExpression="Porcentage_Taux" />
                              <asp:BoundField DataField="Nom_Giac" HeaderText="Nom_Giac" 
                                  SortExpression="Nom_Giac" />
                          </Columns>
                      </asp:GridView>

推荐答案

我认为在 ASP.NET 中没有办法,但你总是可以在 CSS 中做到这一点,只需在模板上使用 HeaderStyle-CssClass.

I don't think there is a way in ASP.NET, but you can always do it in CSS just use HeaderStyle-CssClass on your template.

更新:

好吧,我错了,ASP.NET 确实支持此功能,您只需要在 TemplateField 中使用 HeaderTemplate.

Ok, I was wrong, ASP.NET does support this functionality, you just need use a HeaderTemplate in your TemplateField.

<asp:TemplateField SortExpression="Subnet" HeaderText="Subnet">
   <HeaderTemplate>
       <asp:Label ID="SubnetHeader" ToolTip="My Tip to you" runat="server" Text="Label"></asp:Label>
   </HeaderTemplate>

   <ItemTemplate >  
       <asp:Label ID="lblSubnet" runat="server" Text='<%# Bind("Subnet") %>' ></asp:Label>       
   </ItemTemplate>
</asp:TemplateField>

这篇关于如何在 ASP.NET 中为 gridview 中的每个标题列添加标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆