.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

Readxml in C#.net for Dynamic Property

Posted By: Narayanan     Posted Date: May 25, 2011    Points:5   Category :C#
Hi friends,
Step:1
I have a created Textbox,combo box and check box in my form(Dynamically).
Step:2
Insert values into XML like this structure.
<?xml version="1.0"?>
<Root>
<port0>COM5-Naraayanan-True</port0>
<port1>COM6-Mohan-False</port1>
</Root>
Here ,COM5 is a Combobox value
Naraayanan is a textbox value
True is a Checkbox value(Checked).
But my Problem is when I read a XML. I got a result except Checkbox.Please tell me how to solve my Problem.
I give my readxml coding
gb is a Group Box in my form .
string sFilename = xmlpath;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(sFilename);
XmlElement rootElem = xmlDoc.DocumentElement; //Gets the root element, in your xml its "Root"

for (int i = 0; i < rootElem.ChildNodes.Count ; i++)
{
string name = rootElem.ChildNodes[i].Name;
string value = rootElem.ChildNodes[i].InnerText;
string[] words = value.Split('-');
txt1 = words[0];
txt2 = words[1];
txt3 = words[2];

gb.Controls["Combobox" + (i + 0).ToString()].Text = txt1;
gb.Controls["Textbox" + (i + 0).ToString()].Text = txt2;
gb.Controls["RB" + (i + 0).ToString()].Text = txt3;


}
Last line is problem.Please How to solve my Problem?
Regards,
Lakshmi Narayanan

Responses
Author: Gowthammanju             
Posted Date: May 25, 2011     Points: 20   

Hi,
just code the error message what ur getting,with out that how can we help u


regards,
gowtham

Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true
Author: Narayanan             
Posted Date: May 25, 2011     Points: 20   

hi Gowtham,
Thanks for u reply. I got a answer from my friends.
gb.Controls["RB" + (i + 0).ToString()].Text = txt3;

CheckBox cb = gb.Controls["RB" + i.ToString()] as CheckBox;
cb.Checked = (txt3 == "True");
gb.Controls["RB" + (i + 0).ToString()].Text = "Enabled";
Regards,
Lakshmi Narayanan.S
Keep in tough

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend