What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 9402 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > hw 2 add in dictionary ...
Oswaldlily

hw 2 add in dictionary

Replies: 1 | Posted by: Oswaldlily on 8/21/2012 | Category: C# Forums | Views: 237 | Status: [Member] | Points: 10  


<?xml version="1.0" encoding="utf-8" ?>
<Tables>
<Column col1="c1" col2="c2" col3="c3"></validate>
<Column col1="s1" col2="s2" col3="s3"></validate>
</Tables>

call xml file frm codebehind and add in dictionary.
In dictionary key shd be c1 or s1
value=c2 and c3 or s2 and s3


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Vasanthmvp
Vasanthmvp  
Posted on: 8/21/2012 9:32:48 AM
Level: Starter | Status: [Member] | Points: 25

Hi Oswaldlily,

Here is the solution for you: I'm sure there may be simple way than this, as i am a beginner i tried this way.

ASP Page:
Empty.

CodeBehind:

protected void Page_Load(object sender, EventArgs e)
{

Dictionary<string, string> Items = new Dictionary<string, string>();

DataSet dset = new DataSet();
dset.ReadXml(Server.MapPath("~/DictionaryItems.xml"));

StringBuilder strbkey = new StringBuilder();

foreach (DataRow row in dset.Tables[0].Rows)
{
strbkey.Append(row["col1"]+" ");

}

string x = strbkey.ToString();

string[] keys = x.Split(' ');



StringBuilder strbvalue = new StringBuilder();

foreach (DataRow row in dset.Tables[0].Rows)
{
strbvalue.Append(row["col2"].ToString()+" ");

strbvalue.Append(row["col3"].ToString()+" | ");
}

string y = strbvalue.ToString();

string[] values = y.Split('|');


for (int i = 0; i < values.Count(); i++)
{
Items.Add(keys, values);

}


foreach (KeyValuePair<string, string> item in Items)
{
Response.Write(item);
}

}


Your Xml File: DictionaryItems.xml

<Tables>
<Column col1="c1" col2="c2" col3="c3" />
<Column col1="s1" col2="s2" col3="s3" />
</Tables>


Regards,


Awesome Coding !! :)

Oswaldlily, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/26/2013 3:23:33 AM