How to bnd Linq main Query and sub query results to gridview

Posted by Santhosh.Nallavelli under C# on 8/21/2012 | Points: 10 | Views : 1862 | Status : [Member] | Replies : 0
Hi all ,

I have a Linq Query in the foloowing way .

DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("TestData.xml"));
DataTable dt = ds.Tables[0];

TestData.xml sample structure(only one node as an example given)

<Schedule>
<org>Hyderabad</org>
<des>Bangalore</des>
<Dept>15:40</Dept>
<Arr>21:15</Arr>
</Schedule>


var grps = from p in dt.AsEnumerable()
group p by p["org"].ToString() into g
select new
{
org= g.Key,
rows = (from q in g
select new
{
des = q["des"].ToString() ,
dept = q["Dept"].ToString(),
arr = q["Arr"].ToString(),

}).ToList()
};

gridview1.datasource = grps:
gridview1.databind();

Sample required output :



Hyderabad (This is origin)

Bangalore 15:40 21:15
Mumbai 14:20 16:35


Chennai (Another Origin)

Bangalore 12:20 13:20
Kolkatta 14:50 16:30

---
---
---

This output i need to get .
i am getting only origin cities now like
Hyderabad
Chennai
..
..




Responses

(No response found.)

Login to post response