473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to bind xml to gridview

I'm new to asp.net and i'm trying to bind some XML data to a gridview.
abviously I'm not understanding how to do it properly because that my code doesn't seem to
work...Can anyone could help me please?

this is my xml:
Expand|Select|Wrap|Line Numbers
  1. #########################################
  2. <?xml version "1.0" encoding "utf-8"?>
  3. <dictionary>
  4.   <item>
  5.     <key>
  6.        <string> hello world </string>
  7.     </key>
  8.     <value> <anytype xmlns:q1="http://www.w3.org/2001/XMLSchame" d4p1:type="q1:int"
  9.     xmlns:d4p1="http-instance">45</anytype>
  10.     </value>
  11.   </item>
  12. </dictionary>
and this is my code:
Expand|Select|Wrap|Line Numbers
  1. ########################################
  2. string path = "D:\\myXmlFile.xml";
  3. DataSet oDs = new DataSet();
  4. oDs.ReadXml(path);
  5. GridView1.DataSource = oDs;
  6. GridView1.DataBind();
thanks
Tom
May 22 '10 #1
2 2088
ThatThatGuy
449 Expert 256MB
That XML wouldn't work..
It's not organized as required
The Xml required should be in form of Columns and their values some thing like this...

Expand|Select|Wrap|Line Numbers
  1. <DataSet>
  2. <TableName>
  3. <Col1>CellData1<Col1>
  4. <Col2>CellData2<Col2>
  5. <Col3>CellData3<Col3>
  6. </TableName>
  7. <TableName>
  8. <Col1>CellData1<Col1>
  9. <Col2>CellData2<Col2>
  10. <Col3>CellData3<Col3>
  11. </TableName>
  12. </DataSet>
  13.  
May 24 '10 #2
Curtis Rutland
3,256 Expert 2GB
http://msdn.microsoft.com/en-us/libr...atasource.aspx

Read that whole page, and you should find what you need.
May 24 '10 #3

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

Similar topics

3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
6
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
5
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens...
1
by: joechipubik | last post by:
I have a GridView in a FormView that has as its datasource a DataTable that is stored in the session cache. When I first load the page the GridView is displayed correctly, but on subsequent loads...
3
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
0
by: LiamLiamLiam | last post by:
G'day all. I having a problem with my formview. I'll ty to explain my situation as best as i can. I have a page with a search field at the top which is just a simple asp:textbox. Below that i...
3
by: Peter | last post by:
I have a GridView which is populated by List<ofObjects> Does anyone have example of how to sort the columns of this GridView? I have found examples without DataSourceControl but these use...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.