if(!Page.IsPostBack) { this.PopulateControls(Server.MapPath("RegistrationConfig.xml")); }
public void PopulateControls(string fileName) { try { CustomerRegistrationDetail custDet=new CustomerRegistrationDetail(); RegistrationConfig getConfig=new RegistrationConfig(); custDet = getConfig.GetXMLConfig(fileName); cblRegions.DataSource=custDet.ArlCustomerRegions; cblRegions.DataBind(); cblTypes.DataSource=custDet.ArlCustomerType; cblTypes.DataBind(); } catch(Exception ex) { lblMessage.Text=ex.Message; } }
public CustomerRegistrationDetail GetXMLConfig(string fileName) { CustomerRegistrationDetail det=new CustomerRegistrationDetail (); XmlDocument doc = new XmlDocument(); XPathDocument xpathDoc = new XPathDocument(fileName); XPathNavigator nav=xpathDoc.CreateNavigator(); // Compile a standard XPath expression XPathExpression expr; //Get Custoer Regions expr = nav.Compile("//CustomerRegions/Value"); XPathNodeIterator iterator = nav.Select(expr); while (iterator.MoveNext()) { XPathNavigator nav2 = iterator.Current.Clone(); det.ArlCustomerRegions =GetArrayList(nav2.Value); } //Get Customer Types expr = nav.Compile("//CustomerType/Value"); iterator = nav.Select(expr); while (iterator.MoveNext()) { XPathNavigator nav2 = iterator.Current.Clone(); det.ArlCustomerType =GetArrayList(nav2.Value); } //return the detail object containing all the configuration paramaters return det; }//Utility Function used in above function Functionprivate ArrayList GetArrayList(string strCustParam) { string[] arCust=strCustParam.Split(';'); ArrayList arlRetVal=new ArrayList(); for(int i=0;i { arlRetVal.Add(arCust[i]); } return arlRetVal; }
public class CustomerRegistrationDetail { //variables used to populate Combo boxes in UI public ArrayList ArlCustomerRegions=null; public ArrayList ArlCustomerType=null; }
North West;North East;Yorkshire and HumberSide;West Midlands;East Midlands;London;East of England;South West;South East;Scotland;Wales;Northern Ireland Corporate end-users;Small Business end-users;Residential end-users;Via resellers and dealers