Hi tandoh,
Refer the below sample code.
<asp:GridView runat="server" ID="gvPhoto" />
C#
protected void Page_Load(object sender, EventArgs e)
{
string dept = "Finance";
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/Employee.xml"));
var result = from detail in ds.Tables[0].AsEnumerable()
join emp in ds.Tables[1].AsEnumerable() on detail.Field<Int32>("details_Id") equals emp.Field<Int32>("details_Id")
join photo in ds.Tables[2].AsEnumerable() on emp.Field<Int32>("empFoto_Id") equals photo.Field<Int32>("empFoto_Id")
where detail.Field<string>("dept").ToLower() == dept.ToLower()
select new { photo = photo.Field<string>("foto_Text") };
gvPhoto.DataSource = result;
gvPhoto.DataBind();
}
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim dept As String = "Finance"
Dim ds As New DataSet()
ds.ReadXml(Server.MapPath("~/Employee.xml"))
gvPhoto.DataSource = From detail In ds.Tables(0).AsEnumerable()
Join emp In ds.Tables(1).AsEnumerable() On detail.Field(Of Int32)("details_Id") Equals emp.Field(Of Int32)("details_Id")
Join photo In ds.Tables(2).AsEnumerable() On emp.Field(Of Int32)("empFoto_Id") Equals photo.Field(Of Int32)("empFoto_Id")
Where detail.Field(Of String)("dept").ToLower() = dept.ToLower()
Select New With { _
.photo = photo.Field(Of String)("foto_Text")}
gvPhoto.DataBind()
End Sub
xml
<?xml version='1.0'?>
<information>
<details>
<id>01</id>
<empname>qwer</empname>
<empid>001</empid>
<dept>Accounts</dept>
<date>2011-01-15 12:21:25</date>
<empFoto>
<foto>https://www.raizlabs.com/graiz/wp-content/uploads/sites/8/2013/09/greg_head_A.png</foto>
<foto>https://www.raizlabs.com/graiz/wp-content/uploads/sites/8/2013/09/greg_head_A.png</foto>
</empFoto>
</details>
<details>
<id>02</id>
<empname>jdfklgd</empname>
<empid>002</empid>
<dept>Finance</dept>
<date>2011-01-20 10:21:25</date>
<empFoto>
<foto>https://www.raizlabs.com/graiz/wp-content/uploads/sites/8/2013/09/greg_head_F.png</foto>
<foto>https://www.raizlabs.com/graiz/wp-content/uploads/sites/8/2013/09/greg_head_F.png</foto>
</empFoto>
</details>
</information>
Output
photo |
https://www.raizlabs.com/graiz/wp-content/uploads/sites/8/2013/09/greg_head_F.png |
https://www.raizlabs.com/graiz/wp-content/uploads/sites/8/2013/09/greg_head_F.png |