<ContentTemplate>
<asp:DropDownList ID="ddlCity" runat="server">
/asp:DropDownList>
/ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlState" />
/Triggers>
/asp:UpdatePanel>
XmlTextReader xRead = new XmlTextReader(Server.MapPath("StatesAndCity.xml"));
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("StatesAndCity.xml"));
XmlNodeList xStateList = doc.GetElementsByTagName("state");
for (int i = 0; i <>
{
ddlState.Items.Add(xStateList.Item(i).Attributes.Item(0).Value.ToString());
ddlState.Items[i].Text = xStateList.Item(i).Attributes.Item(0).Value.ToString();
ddlState.Items[i].Value = xStateList.Item(i).Attributes.Item(1).Value.ToString();
// ddlState.SelectedIndex = i;
}
protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
{
ddlCity.Items.Clear();
XmlTextReader xRead = new XmlTextReader(Server.MapPath("StatesAndCity.xml"));
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("StatesAndCity.xml"));
XmlNodeList xStateList = doc.GetElementsByTagName("state");
for (int j = 0; j <>
{
if (xStateList.Item(j).Attributes.GetNamedItem("name").Value == ddlState.SelectedItem.Text)
{
XmlNodeList xCityList = xStateList.Item(j).ChildNodes;// doc.GetElementsByTagName("state").Item(Convert.ToInt32(doc.GetElementsByTagName("state").Item(0).Value)).ChildNodes
for (int i = 0; i <>
{
ddlCity.Items.Add(xCityList.Item(i).Attributes.Item(0).Value.ToString());
}
}
}
0 comments:
Post a Comment