Click here to Skip to main content
16,005,682 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Class dropdown has class titles and Name dropdown has associated names. when a class catogery is selected the associated names should be displayed in the other Namedropdown. i dont want a ajax tool kit control. and the data is in xml file. first dropdown drings the classes but i don't know how to link to second one . plea look at the code in selectIndexchanged and let me know what should i do. thisis my work assignment. the class has id like 1,2,3,4,5,6...the other xml file has names based on the id in class. i'm realating both with id.

C#
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")); 
            } 
 
 
            } 
 
        } 
    }
Posted
Updated 16-Sep-11 8:34am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900