Hi,
I'm working on a web app that displays a couple of dropdownlists (ddl feed from an xml doc). When the app starts the 2 dropdown lists contain the 1st item of their respective lists. What I would like to do is have these values empty until the user makes a selection.
Depending on what the user selects for the first dropdownlist should dictate what options are available on the 2nd dropdownlist when clicked.
Here's my code:
I would greatly appreciate it if someone can point out how to start the app with empty dropdownlists values. Thank you!
I'm working on a web app that displays a couple of dropdownlists (ddl feed from an xml doc). When the app starts the 2 dropdown lists contain the 1st item of their respective lists. What I would like to do is have these values empty until the user makes a selection.
Depending on what the user selects for the first dropdownlist should dictate what options are available on the 2nd dropdownlist when clicked.
Here's my code:
Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
private string xmlPath;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillDropDown();
FillDropDown2();
}
}
private void FillDropDown()
{
this.selection.Items.Clear();
XmlDocument xDoc = new XmlDocument();
xDoc.Load(xmlPath);
XmlNodeList audienceList = xDoc.SelectNodes("/dataroot/List[not(Name=preceding-sibling::List/Name)]/Name");
foreach (XmlNode n in audienceList)
{
ListItem item = new ListItem(n.InnerText, n.InnerText);
this.selection.Items.Add(item);
}
}
private void FillDropDown2()
{
this.selection2.Items.Clear();
XmlDocument xDoc = new XmlDocument();
xDoc.Load(xmlPath);
XmlNodeList audienceList = xDoc.SelectNodes("/dataroot/List[not(Job=preceding-sibling::List/Job)]/Job");
foreach (XmlNode n in audienceList)
{
ListItem item = new ListItem(n.InnerText, n.InnerText);
this.selection2.Items.Add(item);
}
}
}
I would greatly appreciate it if someone can point out how to start the app with empty dropdownlists values. Thank you!