18 February 2016

Load events in Asp.net

load

05 February 2016

Read XML Data for datasource

using System.Xml.Linq;

<?xml version="1.0" encoding="utf-8" ?>
<StatusTypes>
<StatusType Name ="All" value="0"/>
<StatusType Name ="Over-vote" value="1"/>
<StatusType Name ="Mixed Status" value="2"/>
<StatusType Name ="Not Received" value="3"/>
<StatusType Name ="Over Reported" value="4"/>
<StatusType Name ="Under Reported" value="5"/>
<StatusType Name ="In Balance" value="6"/>
</StatusTypes>

string fullName = HttpContext.Current.Server.MapPath(
"~/Modules/Pxy/StatusDataSource.xml");
XDocument doc = XDocument.Load(fullName);
return (from d in doc.Root.Elements("StatusType")
select new KeyValuePair<string,int>( d.Attribute("Name").Value, int.Parse( d.Attribute("value").Value))
).ToList();

statusDataSource DataSource = new statusDataSource();
if (ddlStatus.Items.Count > 0)
ddlStatus.Items.Clear();

ddlStatus.DataSource = null;
foreach (KeyValuePair<string, int> St in DataSource.Status)
ddlStatus.Items.Add(new ListItem(St.Key, St.Value.ToString()));