public partial class orgList : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindClassDropDownList(); } } public void BindClassDropDownList() { string myXMLfile = Server.MapPath("~/OrgClasses.xml"); DataSet CLASS_DATASET = new DataSet(); try { CLASS_DATASET.ReadXml(myXMLfile); ClassDropDownList.DataSource = CLASS_DATASET; ClassDropDownList.DataTextField = "ClASS"; ClassDropDownList.DataBind(); ClassDropDownList.Items.Insert(0, new ListItem("--Select--","0")); } catch (Exception ex) { Response.Write(ex.ToString()); } } protected void ClassDropDownList_SelectedIndexChanged(object sender, EventArgs e) { string myXMLfile = Server.MapPath("~/OrgList.xml"); DataSet NAME_DATASET = new DataSet(); NAME_DATASET.ReadXml(myXMLfile); NameDropDownList.DataSource = NAME_DATASET; if (NameDropDownList.DataSourceID == ClassDropDownList.DataSourceID) { NameDropDownList.DataTextField = "NAME"; NameDropDownList.DataValueField = "ID"; NameDropDownList.DataBind(); } NameDropDownList.Items.Insert(0, new ListItem("--Select--", "0")); if (ClassDropDownList.SelectedValue == "0") { NameDropDownList.Items.Clear(); NameDropDownList.Items.Insert(0, new ListItem("--Select--", "0")); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)