wtbonnell Posted November 5, 2004 Posted November 5, 2004 My goal is to read an .xml into a dataset using .net (C#), so I can dump it into a datagrid. However, I am having trouble reading the .xml file into my dataset. Any ideas what I am doing wrong? This is what my test.xml file looks like: [color=Blue]<book> <title>Book Title</title> <chapter>Chapter 1</chapter> </book>[/color] This is what my code behind looks like: [color=Green]private void Page_Load(object sender, System.EventArgs e) { [indent]if (!IsPostBack) { DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("test.xml")); [color=Olive] // The table name is entitled "title" because //that is the first element in the test.xml file[/color] datagrid1.DataSource = ds.Tables["title"]; datagrid1.DataBind(); }[/indent] }[/color] This is what my .aspx file looks like: [color=Red]<asp:datagrid id="datagrid1" runat="server" AutoGenerateColumns="True"> <Columns><asp:BoundColumn DataField="title"></asp:BoundColumn></Columns> </asp:datagrid>[/color] Quote
Administrators PlausiblyDamp Posted November 5, 2004 Administrators Posted November 5, 2004 What problems are you having exactly? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.