Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2007, 12:10 AM
hanusoft
Guest
 
Posts: n/a
Default example of Inserting and Retrieving data from xml

This is an example of Inserting and Retrieving data from xml file.


private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here

            if(!IsPostBack)
            {
                BindGrid();
            }
        }


private void BindGrid()
        {
            ds = new DataSet();
            try
            {
                ds.ReadXml(@"c:\inetpub\wwwroot\WebApplication10\X MLFile1.xml");
                DataGrid1.DataSource = ds;
                DataGrid1.DataBind();
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }




    private void Button1_Click(object sender, System.EventArgs e)
        {
            ds = new DataSet();
            try
            {
                ds.ReadXml(@"c:\inetpub\wwwroot\WebApplication10\X MLFile1.xml");
                DataRow row = ds.Tables[0].NewRow();
                row["name"]=txtName.Text;
                row["fathersname"]=txtFName.Text;
                row["address"]=txtAddress.Text;
                ds.Tables[0].Rows.Add(row);
                ds.WriteXml(@"c:\inetpub\wwwroot\WebApplication10\ XMLFile1.xml");
                txtAddress.Text="";
                txtFName.Text="";
                txtName.Text ="";
                BindGrid();
            }
            catch(Exception ex)
            {
                throw ex;
            }
 
Old September 26th, 2007, 01:10 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Appreciate your basic work, but there is an inbuilt class (System.Xml) which can handle all the read, insert, update & delete operations. I guess you should study that, it would be more convenient..

Regards
Mike





Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting data into a XML file zion99 ASP.NET 2.0 Basics 0 July 17th, 2006 09:57 AM
inserting data into xml files courseworkhelp BOOK: ASP.NET Website Programming Problem-Design-Solution 1 January 17th, 2006 11:04 PM
Urgent inserting data to database from xml File Venkata Krishnan ADO.NET 1 November 8th, 2005 08:58 AM
inserting some data from xml file to sql server ak Classic ASP XML 1 February 25th, 2004 10:29 AM
Inserting data from Xml to Access Database diptanjan Classic ASP Professional 0 December 1st, 2003 02:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.