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\XMLFile1.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\XMLFile1.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;
			}

hello hanusoft,
i have been trying to insert data from my project which i m doing using asp.net and the language is c#.
i have tried ur code.
it has given 4 errors.
Error 1

'ASP.default_aspx.GetTypeHashCode()': no suitable method found to override
the file where the error occurs

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\firstasp\2e57531e\
3fdfeee\App_Web_komf0cr-.2.cs
the rest of the problem occurs in the same file.
can u tell me what is the wrong with here?

are you using a BasePage or override any methods manually ?

Hi I am creating a Windows Application in C#, for which I am using xml files. I want to insert data into xml file as xml node when I user enter his information into Multi line textboxes. I have tried your above code for asp in my Win forms, but unable to make it work. So please assist me for Windows App

how the xml file should be?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.