ASP.NET Datagrid Sort

windows

Guest
I'm using an XML file as the source document, and I've successfully been able to input that data into an ASP.NET DataGrid with VB.NET (see code below). Now I'd like to allow sorting of that data, but I'm not sure how to accomplish this task. Every tutorial I've seen goes over sorting SQL Server data, so I'm not sure what to do.

So my question is fairly simple:
How do I create a VB.NET script that sorts through XML data using an ASP.NET DataGrid?

If anyone could either point me in the right direction, or post some VB code that could accomploish this, it would be greatly appreciated. Thanks.

Here's the code:
<%@ Page Language="VB" Debug="true" EnableSessionState="false" %>
<%@ import Namespace="System.Data" %>
<%@OutputCache Duration="60" VaryByParam="none" %>
<script runat="server">

'Pulls data
Sub Page_Load
If Not Page.IsPostBack then
Dim xmlFD1 = New
DataSet
xmlFD1.ReadXml("http://SERVER/DIRECTORY/SUBDIRECTORY/docs/xml/formsdocs.xml")
aspxFD1.DataSource = xmlFD1
aspxFD1.DataBind()
End If
End Sub

'Sub formsSort(sender as Object, e as DataGridSortCommandEventArgs)
'...'<---THIS IS WHERE SORT SCRIPT WOULD BE PLACED
'End Sub

</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>PAGETITLE</title>
</head>
<body>
<form runat="server">
<h1>PAGENAME
</h1>
<br />
<asp:DataGrid id="aspxFD1" runat="server"
AllowSorting="True"
HorizontalAlign="Center"
Width="95%"
AutoGenerateColumns="False"
OnSortCommand="formsSort">
<AlternatingItemStyle backcolor="#CCCCFF"></AlternatingItemStyle>
<HeaderStyle font-bold="True"></HeaderStyle>
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="url" DataTextField="title" SortExpression="url" HeaderText="Form/Document"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="type" SortExpression="type" HeaderText="Type"></asp:BoundColumn>
<asp:BoundColumn DataField="dept" SortExpression="dept" HeaderText="Department/Division"></asp:BoundColumn>
<asp:BoundColumn DataField="format" SortExpression="format" HeaderText="Format"></asp:BoundColumn>
<asp:BoundColumn DataField="size" SortExpression="size" HeaderText="Size"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</html>Moved to .NET forum.....as long as I get a response, that's fine by me. Thanks buntine.
 
Back
Top