我有这个:
<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
?
答案 0 :(得分: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>