Abhilash J A

Abhilash J A

  • 530
  • 2.4k
  • 601k

xml data to bind in drowpdownlist using c#

Jan 28 2016 2:55 AM
Hi,

Here is xml data:-

<?xml version="1.0" encoding="utf-8" ?>
<Employee_Info
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="employee.xs">
<Employee Employee_Number="105">
<Name>Masashi Okamura</Name>
<Department>Design Department</Department>
<Telephone>03-1452-4567</Telephone>
<Email>[email protected]</Email>
<Active>False</Active>
</Employee>
<Employee Employee_Number="109">
<Name>Aiko Tanaka</Name>
<Department>Sales Department</Department>
<Telephone>03-6459-98764</Telephone>
<Email>[email protected]</Email>
<Active>True</Active>
</Employee>
<Employee Employee_Number="110">
<Name>Raj</Name>
<Department>Hr Department</Department>
<Telephone>03-6459-123456</Telephone>
<Email>[email protected]</Email>
<Active>True</Active>
</Employee>
</Employee_Info>


and c# code to bind data to dropdowlist:-

protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/XMLDataFile.xml"));
ddlEmp_List.DataSource=ds;
ddlEmp_List.DataTextField = "Name";
ddlEmp_List.DataValueField = "Employee_Number";
ddlEmp_List.DataBind ();
}

from there xml data I want to show only if "Active=True" employee name. How can do?

Answers (3)