Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
Sorted DataView, but unsorted datalist when bound to the dataview
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="CodeMonkey, post: 2979142"] 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="[URL]http://www.w3.org/2001/[/URL] 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> [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
Sorted DataView, but unsorted datalist when bound to the dataview
Top