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.
How do I go about modifying the header text from "Select" to an actual CheckBox
?
From the GridView s smart tag, click on the Edit Templates link and then drag a CheckBox Web control from the Toolbox into the ItemTemplate . Set this CheckBox s ID property to ProductSelector . With the TemplateField and CheckBox Web control added, each row now includes a checkbox.
You can use Header Template
to achieve this and remove the HeaderText
from the Template field
<asp:TemplateField >
<ItemTemplate>
<asp:CheckBox ID="cbSelect" runat="server" AutoPostBack="false"/>
</ItemTemplate>
<HeaderTemplate>
<asp:CheckBox ID="chkBxHeader" runat="server" />
</HeaderTemplate>
</asp:TemplateField>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With