Sorted DataView, but unsorted datalist when bound to the dataview

C

CodeMonkey

Hi all
I create a dataset from an xml file with schema and from the dataset a
sorted dataview. I have tested the contents of the dataview and it is
correctly sorted. However when I bind the dataview to a datalist
control, the rows seem to be swapped. All the data is in the datalist
and changing the sortkeys around does have an effect but I cannot
understand why the order is messed up like this.

Any help is really appreciated.

Andrew

My XML File is further on below. Sorted data in the dataview appears
like this:

STUFF1
STUFF2
STUFF3
STUFF4
STUFF5
STUFF6

but the datalist control on the web page shows it like this:

STUFF1
STUFF4
STUFF2
STUFF5
STUFF3
STUFF6


Here is my code:

Dim abcSwdbNews As DataSet
abcSwdbNews = New DataSet
abcSwdbNews.ReadXml(ConfigurationManager.AppSettings("SwDbNews"),
XmlReadMode.ReadSchema)
'Sort the Dataset - first table - on datbase name
Dim DV As DataView

DV = abcSwdbNews.Tables(0).DefaultView
Dim Value As Type
Value = abcSwdbNews.Tables(0).Columns(0).DataType
'Value correctly returns int32

DV.Sort = "sortkey ASC"

'Set the datasource to the default view
DataList3.DataSource = DV

DataList3.DataBind()


Here is the relavent markup:

<asp:DataList ID="DataList3" runat="server" BackColor="#CCCCCC"
BorderColor="#999999"
BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2"
ForeColor="Black"
GridLines="Both" Style="position: relative" RepeatColumns="2" >
<FooterStyle BackColor="#CCCCCC" />
<SelectedItemStyle BackColor="#000099" Font-Bold="True"
ForeColor="White" />
<ItemStyle BackColor="White" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<HeaderTemplate>
Recent Changes
</HeaderTemplate>
<FooterTemplate>

</FooterTemplate>
<ItemTemplate>
<tr>
<td><%#Container.DataItem("db")%></td>
<td><%#Container.DataItem("Feature")%></td>
</tr>
</ItemTemplate>
</asp:DataList>

Here is the XML file:

<?xml version="1.0" standalone="yes"?>
<Releases>
<xs:schema id="Releases" xmlns="" xmlns:xs="http://www.w3.org/2001/
XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Releases" msdata:IsDataSet="true"
msdata:Locale="en-US">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Release">
<xs:complexType>
<xs:sequence>
<xs:element name="sortkey" type="xs:int"
minOccurs="0" />
<xs:element name="db" type="xs:string" minOccurs="0" / <xs:element name="Feature" type="xs:string"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Databases">
<xs:complexType>
<xs:sequence>
<xs:element name="swdb" type="xs:string"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<Release>
<sortkey>1</sortkey>
<db>STUFF1</db>
<Feature>Some Great Stuff1</Feature>
</Release>
<Release>
<sortkey>2</sortkey>
<db>STUFF2</db>
<Feature>Some Great Stuff2</Feature>
</Release>
<Release>
<sortkey>3</sortkey>
<db>STUFF3</db>
<Feature>Some Great Stuff3</Feature>
</Release>
<Release>
<sortkey>4</sortkey>
<db>STUFF4</db>
<Feature>Some Great Stuff4</Feature>
</Release>
<Release>
<sortkey>5</sortkey>
<db>STUFF5</db>
<Feature>Some Great Stuff5</Feature>
</Release>
<Release>
<sortkey>6</sortkey>
<db>STUFF6</db>
<Feature>Some Great Stuff6</Feature>
</Release>
<Databases>
<swdb>abcSWdb3Q07-02.mde</swdb>
</Databases>
</Releases>
 
J

joyal jhaveri

In the html/inline page, In the datalist property you don't need to use RepeatColumns.

Remove the RepeatColumn from the definition of datalist and try after that.

Thanks.

-J
Joyal Jhaveri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top