473,545 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

example of Inserting and Retrieving data from xml file

4 New Member
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.             }
Sep 25 '07 #1
1 1604
RedSon
5,000 Recognized Expert Expert
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
1527
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 then discription of the person in the 6 line which is a lot of text para and does not have any <br> tag. What I want is to have a script that can...
2
11274
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: BULK INSERT dbo.TestData FROM 'TestData.dat' WITH (CHECK_CONSTRAINTS,
0
1572
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 2000) as follows USERS TABLE
5
2223
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 OleDbConnection1.State = ConnectionState.Closed Then OleDbConnection1.Open() Else
0
1235
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 supported. I must be losing something somewhere, but the byte lengths match up. Is there some encoding I need to do. Please take a look, and...
2
2084
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 data source that can be used with any or the HTML tags that take the src="" attribute). I find it interesting and potentially *very* useful and would...
3
3343
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 records to a data base,for which i am using Typed dataSet.(I used DataSet Designer to create one) Then created a table adapter in which i have written...
1
1661
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 if(!IsPostBack) { BindGrid();
2
2619
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 membership class and trying to insert the rest of the related info with a stored procedure into the custom table I created called aspnet_UserInfo using a...
0
7470
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7405
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7659
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7811
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7760
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5975
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1019
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
709
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.