The SortedAscendingHeaderStyle and SortedDescendingHeaderStyle are not being applied however.
I am not binding my GridView to an asp:SQLDataSource and I read the sorted header styles only work when the gridview is bound to a sqldatasource. Is this the case or could I just be doing something wrong.
Also check what are the styles applied for it, after it renders on the browser. You can use browser developer tools for that. May be some other style is overriding this.
suzyb
Member
47 Points
64 Posts
Sorted heading styles GridView
Jun 11, 2012 09:35 AM|LINK
I am trying to set the class of the header in my GridView when they are sorted. This is my GridView definition
<asp:GridView ID="ContactEnquiries" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" PageSize="10" Width="100%" DataKeyNames="Id" OnPageIndexChanging="ContactEnquiries_PageIndexChanging" OnSorting="ContactEnquiries_Sorting" OnRowDeleting="ContactEnquiries_Deleting" OnRowCommand="ContactEnquiries_RowCommand" CssClass="mGrid" PagerStyle-CssClass="pgr" RowStyle-CssClass="item-bar" AlternatingRowStyle-CssClass="item-bar alt" SortedAscendingHeaderStyle-CssClass="sort-up" SortedDescendingHeaderStyle-CssClass="sort-down">The SortedAscendingHeaderStyle and SortedDescendingHeaderStyle are not being applied however.
I am not binding my GridView to an asp:SQLDataSource and I read the sorted header styles only work when the gridview is bound to a sqldatasource. Is this the case or could I just be doing something wrong.
vijay_myl
Contributor
5070 Points
1068 Posts
Re: Sorted heading styles GridView
Jun 11, 2012 09:53 AM|LINK
hi..
Refer the below link.......
http://www.dotnetcode.in/2012/02/apply-sorting-in-gridview-using-aspnet.html
My .NET blog
Submit Article
suzyb
Member
47 Points
64 Posts
Re: Sorted heading styles GridView
Jun 12, 2012 11:00 AM|LINK
I have got the sorting working. It is just the styling of the header that doesn't work.
Ruchira
All-Star
42906 Points
7023 Posts
MVP
Re: Sorted heading styles GridView
Jun 13, 2012 08:13 AM|LINK
Hello,
It should work. Not sure why it's not working. But try by giving it separte like below
<asp:GridView ID="ContactEnquiries" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" PageSize="10" Width="100%" DataKeyNames="Id" OnPageIndexChanging="ContactEnquiries_PageIndexChanging" OnSorting="ContactEnquiries_Sorting" OnRowDeleting="ContactEnquiries_Deleting" OnRowCommand="ContactEnquiries_RowCommand" CssClass="mGrid" PagerStyle-CssClass="pgr" RowStyle-CssClass="item-bar" AlternatingRowStyle-CssClass="item-bar alt"> <SortedAscendingHeaderStyle CssClass="sort-up" /> <SortedDescendingHeaderStyle CssClass="sort-down" />Also check what are the styles applied for it, after it renders on the browser. You can use browser developer tools for that. May be some other style is overriding this.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.suzyb
Member
47 Points
64 Posts
Re: Sorted heading styles GridView
Jun 13, 2012 11:27 AM|LINK
That didn't work either :/
The sort-up and sort-down classes are just not being applied at all. I chceked in firebug and they are nto being applied to any element of the table.
It's not a huge issue, more cosmetic but if it should work and it isn't it's rather puzzling.
bonfil1
Member
2 Points
1 Post
Re: Sorted heading styles GridView
Dec 21, 2012 06:24 PM|LINK
I have the same problem and i dont get it, why is doin this, mi GridView is something like this:
<asp:GridView ID="gvwContactos" runat="server" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" OnSorting="gvwContactos_Sorting" OnPageIndexChanging="gvwContactos_PageIndexChanging" PageSize="15" onrowcommand="gvwContactos_RowCommand" OnRowDataBound="gvwContactos_RowDataBound"> <SortedAscendingHeaderStyle CssClass="sort_col_up" /> <SortedDescendingHeaderStyle CssClass="sort_col_down" /> <Columns> <asp:TemplateField HeaderText="Título" SortExpression="Titulo" HeaderStyle-BackColor="#159EBE" HeaderStyle-ForeColor="White" HeaderStyle-BorderColor="Black" > <ItemTemplate> <asp:Label ID="lblTitulo" runat="server" Text='<%# Bind("Titulo") %>' ToolTip ='<%# Bind("Titulo") %>' /> <asp:HiddenField ID="id_padre_principal_oculto" Value='<%# Bind("IdPadrePrincipal") %>' Visible="false" runat="server"/> </ItemTemplate> </asp:TemplateField>