[英]how do I add a CheckBox to a TemplateField HEADER?
I have this: 我有这个:
<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>
Which gives me this: 这给了我这个:
I want to change where the highlighted word "SELECT"
is to an actual CheckBox
so that when the user checks it, it checks all boxes under. 我想将突出显示的单词
"SELECT"
更改为实际的CheckBox
以便当用户选中它时,它会选中下面的所有复选框。
How do I go about modifying the header text from "Select" to an actual CheckBox
? 如何将标题文本从“选择”修改为实际的
CheckBox
?
You can use Header Template
to achieve this and remove the HeaderText
from the Template field 您可以使用
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.