简体   繁体   English

如何将CheckBox添加到TemplateField HEADER?

[英]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.

相关问题 如何通过代码隐藏使复选框创建TemplateField? - How Do I Make a TemplateField with Checkbox Through Code-behind? 如何以编程方式添加TemplateField - How to add TemplateField programmatically 如何居中对齐 TemplateField 的标题文本? - How to center align the header text of a TemplateField? 如何在iTestSharp中的PdfCell中添加一个复选框? - How do I add a checkbox to PdfCell in iTestSharp? 更改数据绑定Templatefield(复选框)的值时,执行更新语句 - Do an update statement when Value of a databound Templatefield(checkbox) is changed 如何将复选框的文本绑定到Expander的页眉 - How do I bind text of checkbox to Header of Expander 如何在Swashbuckle中添加标题文档? - How do I add header documentation in Swashbuckle? 如何在选择数据网格WPF的复选框标头时编写代码以选择/取消选择所有复选框? - How do I write code to select/unselect all checkbox on selecting checkbox header of data grid WPF? 如何在DatagridviewCheckBoxColumn的Header添加复选框控件? - How to add checkbox control at the Header of DatagridviewCheckBoxColumn? 我想在现有的复选框gridview表中添加新的复选框行,也想在数据库中添加该新的复选框行 - I want to add new checkbox rows in existing checkbox gridview table and also want to add that new checkbox row in database how will i do it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM