---
title: "Populate drop downlist with an xml file"  
description: "Populate drop downlist with an xml file"  
author: "Anonymous User"  
published: 2013-05-20  
updated: 2013-05-20  
canonical: https://www.mindstick.com/forum/919/populate-drop-downlist-with-an-xml-file  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# Populate drop downlist with an xml file

Hi [Developers](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs),\
I have two [dropdownlist](https://www.mindstick.com/articles/324837/how-to-bind-dropdownlist-in-mvc-core-from-database-using-entity-framework) in my app [country](https://yourviews.mindstick.com/view/85543/do-you-think-that-french-will-be-islamic-country) and state and i have to [populate](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) them through an [xml file](https://www.mindstick.com/forum/360/how-to-read-xml-file-in-php).I have written the following code: \
\
ds = new [DataSet](https://www.mindstick.com/articles/19/dataset)(); ds.ReadXml([Server.MapPath](https://www.mindstick.com/forum/2132/server-mappath-in-asp-dot-net)("~/country_state.xml")); LoadCountryDropdownList();\
[public void](https://www.mindstick.com/interview/2715/can-we-write-static-public-void-instead-of-public-static-void) LoadCountryDropdownList() { ddlCountry.DataTextField = "name"; ddlCountry.DataValueField = "country_Id"; ddlCountry.DataSource = ds.Tables["country"]; ddlCountry.DataBind(); LoadStateDropdownList(ddlCountry.SelectedValue); }\
[private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) void LoadStateDropdownList(string country_Id) { }\
through this code i have achieved data [reading](https://www.mindstick.com/articles/126273/books-commonly-found-on-college-reading-lists) from an xml file is done and i have also populate the country dropdownlist listnow i have to populate the state dropdownlist list on the basis of country dropdownlist.\
Thanks in advance.

## Replies

### Reply by Sumit Kesarwani

Hi Jacob,\
try this code in your app\
ddlState.DataTextField = "state_Text"; DataView dv = new DataView(ds.Tables["state"]); dv.RowFilter = "country_Id = " + country_Id; ddlState.DataSource = dv.ToTable(); ddlState.DataBind();\
I hope this code will solve your problem.


---

Original Source: https://www.mindstick.com/forum/919/populate-drop-downlist-with-an-xml-file

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
