i have a gridview in asp.net/vb and it is bound to a list – so there’s no standard sorting available.
I’ve found this jQuery plugin for sorting tables: http://tablesorter.com/
The plugin requires <thead> and <tbody>.
The problem is, that my gridview only renders the <tbody>.
I’ve already tried
DataList.UseAccessibleHeader = True
DataList.HeaderRow.TableSection = TableRowSection.TableHeader
but this changes nothing.
My gridview markup:
<asp:GridView runat="server" CssClass="grid" ID="DataList" AutoGenerateColumns="False" AllowSorting="True" ClientIDMode ="Static">
<Columns>
<asp:BoundField HeaderText="SomeHeaderText" DataField="SomeDataField" />
<asp:BoundField HeaderText="SomeHeaderText" DataField="SomeDataField" DataFormatString="{0:dd.MM.yyyy}" />
<asp:BoundField HeaderText="SomeHeaderText" DataField="SomeDataField" DataFormatString="{0:dd.MM.yyyy}" />
<asp:TemplateField>
<HeaderTemplate>
<asp:Panel runat="server" ID="Panel1" HorizontalAlign="Center">
<asp:Label Text="xxx" runat="server" ID="xxx" />
</asp:Panel>
</HeaderTemplate>
<ItemTemplate>
<asp:Panel runat="server" ID="Panel2" HorizontalAlign="Center">
<asp:Image ID="Image1" ImageUrl="./myImage.png" runat="server" Height="20px" />
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
What can i do?
If you are not going to use the paging feature of the gridview control so i suggest that you move to the “Repeater” as it will give you the power to format the table header section and footer and it will give you the power of rendering the table exactly as you want it to be rendered.