471,350 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Problem Loading XML into dataset and binding to gridview

This is a 2 part question:

Part 1:
I am accesing a web service that returns an xml string of user information. I am attempting to load the XML into an XMLDocument, save the document, load it into a dataset, and bind the dataset to a gridview.

I'm not sure if it's neccesary to save the XML file to disk, but I wanted to make sure it was well formed. It is.

No exceptions are caught during the loading and binding process, but my gridview only displays the first 2 attribute values of the parent node (the first datarow). Any ideas as to why this would happen?

Part 2:
I need to filter the data based on several attribute values in the XML file. Is this more efficient pre-dataset or post-dataset? At a high-level, how would one go about doing either?

Here is the code:

Private Sub GetMembers()
Dim tSessionId As String = Session("TimssSessionId").ToString
Dim wsTimssCustomer As New wsTimssCustomer.TIMSSCustomer
Dim xmlDocMembers As New XmlDocument
Dim oDataSet As DataSet
Dim sXMLMembersFile As String = Server.MapPath("xmldocuments/members.xml")

'Open a new call to the web service thru the web reference
Dim wsTimssCusGet As wsTimssCustomer.TIMSSCustomer = New wsTimssCustomer.TIMSSCustomer()

'Use the GetCustomers Web Service passing session id, field names, values
Dim MemberXml As String = wsTimssCusGet.GetCustomers(tSessionId, "FirstName, LastName", "Jason, Abney")

'Load the return in an XML Document
xmlDocMembers.LoadXml(MemberXml)
xmlDocMembers.Save(sXMLMembersFile)

Try
oDataSet = new DataSet
oDataSet.ReadXml(sXMLMembersFile)

'Bind it to the gridview
gvMembers.DataSource = oDataSet.Tables(0)
gvMembers.DataBind()
Catch ex As Exception
Response.Write(ex.ToString)
End Try
End Sub
Jun 17 '07 #1
6 4822
kenobewan
4,871 Expert 4TB
Welcome to TSDN. I assume both problems could be resolved through ado.net and modifying queries. HTH.
Jun 17 '07 #2
Thank you for your response. That's a little ambiguous however. Could you elaborate please?

Thank you
Jun 17 '07 #3
kenobewan
4,871 Expert 4TB
Here is an article that may help:
Programmatically using ADO.NET and XML
Jun 18 '07 #4
That has very little to do with what I am trying to accomplish. Thanks anyway.
Jun 18 '07 #5
TRScheel
638 Expert 512MB
Edited to read more into the problem...


Have you tried binding directly into the DataSet?


Also, can you post the HTML of your gridview?
Jun 18 '07 #6
I am binding directly to the dataset. Here's the code:
oDataSet = New DataSet
oDataSet.ReadXml(sXMLMembersFile)
gvMembers.DataSource = oDataSet
gvMembers.DataBind()


Here's the HTML of the gridview:
<asp:GridView ID="gvMembers" runat="server">
</asp:GridView>
Jun 18 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Tom Vukovich | last post: by
5 posts views Thread by sck10 | last post: by
reply views Thread by Adam Sandler | last post: by
2 posts views Thread by =?Utf-8?B?VmFpYmhhdg==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.