XML DataSet/DataView equivalent of SQL "Select TOP X..."?

I have an XML file loaded into a DataSet (ds)...
Created a DataView (dv) on ds...
Filtered through data with dv.RowFilter = "something > somethingelse"
I would like to only return first 2 rows of data (instead of every row that meets dv.RowFilter criteria) for my DataView to bind to a DataList...

Is this possible?

Tx for any input...
0
robdown
8/19/2005 4:38:25 PM
asp.net.xml-datasource 7181 articles. 0 followers. Follow

1 Replies
431 Views

Similar Articles

[PageSpeed] 6

I figured this out on my own...I'll post what I did below just in case someone else needs it. (in VB.NET)


Dim myDS As New DataSet()
Dim myDV As DataView
Dim pagedData As New PagedDataSource()
Dim iLen, iWid As Integer

iLen = CType(tbLength.Text, Integer) 'from user input textbox
iWid = CType(tbWidth.Text, Integer) 'from user input textbox

'Load XML into DataSet
myDS.ReadXml(Server.MapPath("someXMLFile.xml"))

'Create DataView, Filter and Sort results
myDV = myDataSet.Tables(0).DefaultView
myDV.RowFilter = "length >= " & iLen & " AND width >= " & iWid
myDV.Sort = "length, width"

'Assign returned DataView to PagedDataSource and set page size
pagedData.DataSource = myDV
pagedData.AllowPaging = True
pagedData.PageSize = 2

'Bind paged result to web control (in this case, a Repeater)
rptSizes.DataSource = pagedData
rptSizes.DataBind()


Of course, you can dive deeper into the PagedDataSource class to implement paging, but all I wanted to do was return a portion of data...this did the trick. If there are any other better options, please post!! L8tr...
0
robdown
8/19/2005 7:17:38 PM
Reply:

Similar Artilces:

How to read the xml returned by select query with "For XML Auto,Elements"
Hi all,  I am writing a select query which produces huge xml data.Now i want to read that data from my web application a save it as xml file. How can i do that. I am using asp.net vb.net.  Check if this post is helpful.http://forums.asp.net/t/1182514.aspx Thanks,Dhimant Trivedi"When the going gets tough, tough gets going.""Mark as Answer" the post(s) which helped you solve the problem...

passing a "recordset" as xml from the middle to top tier. better idea than a dataset?
Hey everyone;I was hoping I could get some advice from you folks. When I would get data directly out of a sql server, I was always advised to use the command object and a datareader, because they are both fast and as lightweight as you can get for doing that type of operation (hitting a stored procedure and getting a recordset back).Now that I'm building a lot more web services for our top tiers to consume, I keep getting into the habit of returning a dataset. I've always read that these are heavy objects which if you don't need them, you shouldn't use them.Would I be better off returning a ...

"Initialize Active Directory for Hosting" Fails
Trying to get HMC set up and installed on a new server; been following the step-by-step instructions included with the software.  Everything's was going smoothly until I got to the "Initialize Active Directory for Hosting" step, at which point I started getting this error: "Only one top level element is allowed in an XML document".  I haven't been able to find any info on this error as it relates to an MPS deployment, and haven't made much progress moving past it.  Here's the proc.xml that provtest is trying to process and failing on:<req...

Whether there is a difference between execution "SELECT FIRST" and "SELECT TOP 1" ?
Hello All. ASA 8.0.2.3608 for Linx There is table INPASSINGDOC. In it where that 95000 records. The field INPASSINGDOC.INCOMINGCODE integer it of FK a field and on it is a system index. On a field DOCBOSSDATE date as there is an index: CREATE INDEX IND_DOCBOSSDATE_TIME ON DBA.INPASSINGDOC (DOCBOSSDATE ASC, DOCBOSSTIME ASC) I make inquiry: select first IDENTITY from dba.INPASSINGDOC where INCOMINGCODE = 88754 order by DOCBOSSDATE asc; This inquiry fulfils rather long - where that 2-3 seconds. Here the schedule of this inquiry: === Schedule of inquiry === ( Plan [Total C...

"Attempt to use an "XML" extension that has not been registered..."
Hello, I am using Reporting Service in server mode.I currently have a report in which in include a few subreports. All of them use the same datasource (sqlserver 2005 database connectionstring)I have to add another report which is based on XML data. To do so, I created a new shared datasource, designed my query, added the report parameters, tested the query... This works but when I try to deploy this report on the report server I am getting an error I do not understand:"Attemps to use an "XML" extension of data that has not been registered for this report server"I do...

Printing options for "txt" Emails: No "print selection", "print pages X to Y" ??
Hi. NTS told me, that for TEXT only emails it is not possible, to get the same "print..." dialog, as it's available for HTML formatted email: - Printing selected text - Printing a page range I was advised, to place an enhancement request (done). It's hard to believe, that there really isn't some work around to print just parts of TEXT emails, or a page range?? Regards, Rudi. Rudolf, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem...

superreview granted: [Bug 211046] In <chrome://global/content/bindings/tree.xml>, "Error: this.treeBoxObject.selection has no properties" : [Attachment 146534] (Av2) <tree.xml>
jag (Peter Annema) <jag@tty.nl> has granted Serge GAUTHERIE <gautheri@noos.fr>'s request for superreview: Bug 211046: In <chrome://global/content/bindings/tree.xml>, "Error: this.treeBoxObject.selection has no properties" http://bugzilla.mozilla.org/show_bug.cgi?id=211046 Attachment 146534: (Av2) <tree.xml> http://bugzilla.mozilla.org/attachment.cgi?id=146534&action=edit ------- Additional Comments from jag (Peter Annema) <jag@tty.nl> var c = this.currentIndex; - var l = this.treeBoxObject.view.rowCount - 1; + var l = this.v...

superreview requested: [Bug 211046] In <chrome://global/content/bindings/tree.xml>, "Error: this.treeBoxObject.selection has no properties" : [Attachment 146534] (Av2) <tree.xml>
Serge GAUTHERIE <gautheri@noos.fr> has asked jag (Peter Annema) <jag@tty.nl> for superreview: Bug 211046: In <chrome://global/content/bindings/tree.xml>, "Error: this.treeBoxObject.selection has no properties" http://bugzilla.mozilla.org/show_bug.cgi?id=211046 Attachment 146534: (Av2) <tree.xml> http://bugzilla.mozilla.org/attachment.cgi?id=146534&action=edit ...

superreview granted: [Bug 211046] In <chrome://global/content/bindings/tree.xml>, "Error: this.treeBoxObject.selection has no properties" : [Attachment 147569] (Av2b) <tree.xml>
Serge GAUTHERIE <gautheri@noos.fr> has granted Serge GAUTHERIE <gautheri@noos.fr>'s request for superreview: Bug 211046: In <chrome://global/content/bindings/tree.xml>, "Error: this.treeBoxObject.selection has no properties" http://bugzilla.mozilla.org/show_bug.cgi?id=211046 Attachment 147569: (Av2b) <tree.xml> http://bugzilla.mozilla.org/attachment.cgi?id=147569&action=edit ------- Additional Comments from Serge GAUTHERIE <gautheri@noos.fr> Keeping: {{ (Av2) <tree.xml> patch 2004-04-19 15:57 PDT varga: review+ jag: super...

XML to DataSet "kind of" works...
I need a little help with XML... I have an XML file 'products.xml' that gets updated 4 times a day. Our ASP.net application hits up the XML file every hour. This is how the XML looks like... <Product ID="3829173"> <Name>Purple Cow</Name> <Desc>Blah blah blah</Desc> <Quantity>5</Quantity> <PricingLevels> <Regular>9.99</Regular> <Valued>8.99</Valued> <Employee>4.99</Employee> </PricingLevels> </Product> When I bind the XM...

"XML page cannot be displayed" added to XML Download
I'm using these lines to initiae a download of an xml file.  Response.Clear()Response.ContentType = "application/octet-stream"Response.AddHeader("Content-Disposition", _"attachment; filename=""" & varFileName & """")Response.Flush()Response.WriteFile(varFileName)   File looks fine in XML viewer just after created. But the output of the download, when viewed as XML, has the following, fully formatted http error imbedded in it:   XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh butto...

"x = " vs. "var x = "
Just a quick q: why does the expression "var x = 5" return "undefined"? The expression "x = 5" returns 5, as I would expect. Inside jsshell "var x = 5" doesn't print a value (I assume it's suppressing undefined results). Sterling Sterling Bates wrote: > Just a quick q: why does the expression "var x = 5" return "undefined"? This is not an expression. This is a statement, declaring a variable x initializing it with 5. > The expression "x = 5" returns 5, as I would expect. This is an e...

convert BASDA format XML to "standard" XML
hiya, Many of my recent problems have been that I have found it difficult to get my head round using XSLT on BASDA format XML.I feel that it would be easier to convert the BASDA format to "standard" XML, then do my XSLT. --BASDA snippet <rows> <row> <FIELD NAME="PRODUCT-TYPE">CAR</FIELD> <FIELD NAME="PRODUCT-DATE">01/01/2004</FIELD> </row> </rows> --what I regard as "standard" XML...easier to work with. <rows> <row> <PRODUCT-TYPE>CAR</P...

superreview requested: [Bug 211046] In <chrome://global/content/bindings/tree.xml>, "Error: this.treeBoxObject.selection has no properties" : [Attachment 156642] (Bv1a) <tree.xml> (/Toolkit part)
[Checked in: Comment n] Serge GAUTHERIE <gautheri@noos.fr> has asked jag (Peter Annema) <jag@tty.nl> for superreview: Bug 211046: In <chrome://global/content/bindings/tree.xml>, "Error: this.treeBoxObject.selection has no properties" http://bugzilla.mozilla.org/show_bug.cgi?id=211046 Attachment 156642: (Bv1a) <tree.xml> (/Toolkit part) [Checked in: Comment n] http://bugzilla.mozilla.org/attachment.cgi?id=156642&action=edit ...

Web resources about - XML DataSet/DataView equivalent of SQL "Select TOP X..."? - asp.net.xml-datasource

Resources last updated: 12/28/2015 2:39:09 AM