5

我有这个:

<asp:GridView ID="gvShows" runat="server" HorizontalAlign="Center" DataKeyNames="dataSource,title" Caption="Show List" AutoGenerateColumns="False" AllowSorting="True" CaptionAlign="Top" OnSorting="gvShows_Sorting">
<RowStyle BorderColor="Black" />
<Columns> 
    <asp:TemplateField HeaderText="Select" > 
        <ItemTemplate> 
            <asp:CheckBox ID="cbSelect" runat="server" AutoPostBack="false"/> 
        </ItemTemplate> 
    </asp:TemplateField> 
    <asp:BoundField HeaderText="Data Source" DataField="DataSource" SortExpression="DataSource"/> 
    <asp:BoundField HeaderText="Show Title" DataField="Title" SortExpression="Title"/> 
    <asp:BoundField HeaderText="Episode Title" DataField="EpisodeTitle"     SortExpression="EpisodeTitle"/> 
    <asp:BoundField HeaderText="Genre" DataField="Genre" SortExpression="Genre"/> 
    <asp:BoundField HeaderText="Show Type Description" DataField="ShowTypeDescription" SortExpression="ShowTypeDescription"/> 
    <asp:BoundField HeaderText="Director Name" DataField="DirectorName" SortExpression="DirectorName"/> 
    <asp:BoundField HeaderText="Release Year" DataField="ReleaseYear" SortExpression="ReleaseYear"/> 
    <asp:BoundField HeaderText="Season Episode" DataField="SeasonEpisode" SortExpression="SeasonEpisode"/> 
    <asp:BoundField HeaderText="Show ID" DataField="ShowId" SortExpression="ShowId"/> 
    <asp:BoundField HeaderText="Episode ID" DataField="EpisodeID" SortExpression="EpisodeID"/> 
</Columns>  

这给了我这个:

我想将突出显示的单词"SELECT"的位置更改为实际位置CheckBox,以便当用户检查它时,它会选中下面的所有框。

如何将标题文本从“选择”修改为实际CheckBox

4

1 回答 1

5

您可以使用Header Template来实现这一点并HeaderText从模板字段中删除

 <asp:TemplateField > 
  <ItemTemplate> 
     <asp:CheckBox ID="cbSelect" runat="server" AutoPostBack="false"/> 
   </ItemTemplate> 

  <HeaderTemplate>
    <asp:CheckBox ID="chkBxHeader" runat="server" />
    </HeaderTemplate>
 </asp:TemplateField>  
于 2013-07-08T16:38:41.530 回答