I created a Dynamic textbox and insert a value into XML.I send my code for u reference.
My code for XML Creation.
string sFilename = xmlpath;
XmlDocument xmlDoc = new XmlDocument();
String XmlSpecification = "";
XmlSpecification = XmlSpecification + Environment.NewLine + "
File.AppendAllText(xmlpath, XmlSpecification);
xmlDoc.Load(sFilename);
XmlElement elmXML = xmlDoc.CreateElement("Configuration");
string strConfiguration = String.Empty;
for (int index = 0; index < 3; index++)
{
string targetTextBox = "Textbox" + index;
//Try to find the textbox
int textBoxIndex = gb.Controls.IndexOfKey(targetTextBox);
if (textBoxIndex != -1)
{
TextBox foundTextBox = (TextBox)gb.Controls[textBoxIndex];
Userprefrenece.txt1 = foundTextBox.Text;
}
String str = "port" + index.ToString();
strConfiguration = strConfiguration + Environment.NewLine + @"
}
elmXML.InnerXml = strConfiguration;
xmlDoc.DocumentElement.AppendChild(elmXML);
xmlDoc.Save(sFilename);
MessageBox.Show("Saved Successfully");
I saved successfully. How can retrieve from XML. But I didn't get correct.
My XML Data
-
-
retrieve is my problem.How can i retrieve data from xml.and store in the textbox .Please help me Urgent
Regards,
Lakshmi Narayanan.S

VulpesPosted May 26, 2011, 6:29 AM
// ....
XDocument doc = XDocument.Load(sFileName);
textBox1.Text = doc.ToString(); // textBox1 assumed to be multiline