473,383 Members | 1,832 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,383 software developers and data experts.

Example of Inserting and Retrieving data from xml file

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


Expand|Select|Wrap|Line Numbers
  1. private void Page_Load(object sender, System.EventArgs e)
  2.         {
  3.             // Put user code to initialize the page here
  4.  
  5.             if(!IsPostBack)
  6.             {
  7.                 BindGrid();
  8.             }
  9.         }
  10.  
  11.  
  12. private void BindGrid()
  13.         {
  14.             ds = new DataSet();
  15.             try
  16.             {
  17.                 ds.ReadXml(@"c:\inetpub\wwwroot\WebApplication10\XMLFile1.xml");
  18.                 DataGrid1.DataSource = ds;
  19.                 DataGrid1.DataBind();
  20.             }
  21.             catch(Exception ex)
  22.             {
  23.                 throw ex;
  24.             }
  25.         }
  26.  
  27.  
  28.  
  29.  
  30.     private void Button1_Click(object sender, System.EventArgs e)
  31.         {
  32.             ds = new DataSet();
  33.             try
  34.             {
  35.                 ds.ReadXml(@"c:\inetpub\wwwroot\WebApplication10\XMLFile1.xml");
  36.                 DataRow row = ds.Tables[0].NewRow();
  37.                 row["name"]=txtName.Text;
  38.                 row["fathersname"]=txtFName.Text;
  39.                 row["address"]=txtAddress.Text;
  40.                 ds.Tables[0].Rows.Add(row);
  41.                 ds.WriteXml(@"c:\inetpub\wwwroot\WebApplication10\XMLFile1.xml");
  42.                 txtAddress.Text="";
  43.                 txtFName.Text="";
  44.                 txtName.Text ="";
  45.                 BindGrid();
  46.             }
  47.             catch(Exception ex)
  48.             {
  49.                 throw ex;
  50.             }
Oct 1 '07 #1
1 1649
RedSon
5,000 Expert 4TB
The account of member hanusoft has been banned for a period of one week. Cross posting, failure to use code tags and spamming your website are against site rules. Please read the posting guidelines.

-MODERATOR
Nov 6 '07 #2

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

Similar topics

2
by: Jaunty Edward | last post by:
Hi, My problem is a little advance I feel, please check it and guide me if you can. I have a lot of similar format text files, that has name in the first line then age in forth line second and...
2
by: tperovic | last post by:
Using SS2K, I'm getting the following error while bulk inserting: Column 'warranty_expiration_date' cannot be modified because it is a computed column. Here is my bulk insert statement: ...
0
by: Alistair | last post by:
Hi all, I am creating a database based site that keeps track of books, who has read them and the comments they have. After a little help in M.P.I.asp.DB I managed to create a database (access...
5
by: aniket_sp | last post by:
i am using a data adapter and a dataset for filling and retrieving data into .mdb database. following is the code..... for the form load event Dim dc(0) As DataColumn Try If...
0
by: kid4rilla | last post by:
I can successfully write the binary data to an image data type, and successfully retrieve it, but when I attempt to play the file in media player after retrieving it, I get the file type isn't...
2
by: Richard Maher | last post by:
Hi, Recently on the web I came across documentation discussing Data Source Objects (DSO) in relation to browser and html functionality (in particular the ability to declare a Java applet as a...
3
by: Surya | last post by:
Dear All, I have problem on inserting a record to database..Although it looked easy.. i have caught up with following issue .. please go ahead and help me to find solution I Need to insert...
1
by: hanusoft | last post by:
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 ...
2
by: cluce | last post by:
I am trying to read a csv file with user info (username, password, email, address, city, zip, state, etc.) I am inserting the username, password, email into the aspnet_memberhsip table using the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.