tag:blogger.com,1999:blog-545731633430495758.post4178649784223128991..comments2024-03-28T00:33:37.133-07:00Comments on .Net Tutorial: Bind XML saving data to DataGridView with Delete and Edit Options in Windows forms applicatons using C# || Insert,Edit,Delete data into XML with DataGridView in Windows forms using C#Nareshhttp://www.blogger.com/profile/00914286278852775630noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-545731633430495758.post-77070588100412062742013-11-07T02:02:42.278-08:002013-11-07T02:02:42.278-08:00The DataGridView support data binding to xml file ...The <a href="http://www.kettic.com/winforms_ui/csharp_guide/gridview_populate_data_binding_xml.shtml" rel="nofollow">DataGridView support data binding to xml file</a> data source through datatable in Windows application.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-545731633430495758.post-88951403693522180482012-10-20T01:04:18.893-07:002012-10-20T01:04:18.893-07:00An "Xpathexception has an invalid token"...An "Xpathexception has an invalid token" runtime exception is raised.Anonymoushttps://www.blogger.com/profile/01220414899726356529noreply@blogger.comtag:blogger.com,1999:blog-545731633430495758.post-86314771428607806942012-05-14T03:02:56.904-07:002012-05-14T03:02:56.904-07:00In the above code the difference is that when the ...In the above code the difference is that when the parent node already created we dont required to create that parent node again.For example in the above "BankAccount_Details" is the root node once we create that one we have to append the child nodes to it with out creation of that root node.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-545731633430495758.post-6399182340709462512012-05-14T02:55:55.364-07:002012-05-14T02:55:55.364-07:00Write this code to save the data into xml file.
pr...Write this code to save the data into xml file.<br />private void btnSave_Click(object sender, EventArgs e)<br /> {<br />string path = "AccountDetails1.xml";<br /> XmlDocument doc = new XmlDocument();<br /><br /> XmlElement rootElement;<br /><br /> //if there is no current file then create one<br /> if (!System.IO.File.Exists(path))<br /> {<br /> //Create Necessary Nodes<br /> XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes");<br /> XmlComment com = doc.CreateComment("This is an XML Generated File");<br /> doc.AppendChild(declaration);<br /> doc.AppendChild(com);<br /> rootElement = doc.CreateElement("BankAccount_Details");<br /><br /> }<br /> else//if there is already a file<br /> {<br /> //Load Xml File<br /> doc.Load(path);<br /> rootElement = doc.DocumentElement;<br /> }<br /><br /> //get the Root Element<br /> XmlElement subroot = doc.CreateElement("BankAccount");<br /> rootElement.AppendChild(subroot);<br /> XmlElement BankName = doc.CreateElement("BankName");<br /> subroot.AppendChild(BankName);<br /> XmlElement AccountNumber = doc.CreateElement("AccountNumber");<br /> subroot.AppendChild(AccountNumber);<br /> XmlElement BankType = doc.CreateElement("BankType");<br /> subroot.AppendChild(BankType);<br /> XmlElement Balance = doc.CreateElement("Balance");<br /> subroot.AppendChild(Balance);<br /> //Add the values for the each node<br /> BankName.InnerText = (comboBox1.SelectedItem as ComboBoxItem).Content.ToString();<br /> AccountNumber.InnerText = textBox1.Text;<br /> if (radioButton1.IsChecked == true)<br /> {<br /> BankType.InnerText = radioButton1.Content.ToString();<br /> }<br /> else if (radioButton2.IsChecked == true)<br /> {<br /> BankType.InnerText = radioButton2.Content.ToString();<br /> }<br /> else<br /> {<br /> BankType.InnerText = radioButton3.Content.ToString();<br /> }<br /> Balance.InnerText = textBox2.Text.ToString();<br /> doc.AppendChild(rootElement);<br /><br /><br /> //Construct The Document<br /> doc.Save(path);<br /> MessageBox.Show("Records added Successfully");<br /><br /> //Reset text fields for new input<br /> textBox1.Text = String.Empty;<br /> textBox2.Text = String.Empty;<br /> comboBox1.SelectedIndex = 0;<br /> LoadGrid();<br /> }Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-545731633430495758.post-67671214758362861372012-05-12T04:56:38.390-07:002012-05-12T04:56:38.390-07:00In the above code u declared the xmldecaration and...In the above code u declared the xmldecaration and xmlcomment as local object how can u use them to append to the doc object.Once check the code.Anonymousnoreply@blogger.com