bind gridview from 2 tables using xml linq query
i have a xml which contain 13 tables , i want to join two tables .to display 2 tables data in 1 gridview , i am using linq query but it is not working properly the code is below plz see it and tell me right suggestion.
var employeeinfo = from p in ds2.Tables[11].AsEnumerable()
join c in ds2.Tables[12].AsEnumerable()
on p.Field<int>("TPA_Extensions_Id") equals c.Field<int>("TPA_Extensions_Id") into UP
from c in UP.DefaultIfEmpty()
select new
{
TPA_Extensions_Id = p.Field<int>("TPA_Extensions_Id"),
BasicPropertyInfo_Id = p.Field<int>("BasicPropertyInfo_Id"),
RPH = c.Field<int>("RPH")
};
GridView1.DataSource = employeeinfo;
GridView1.DataBind();
vipin sainiPosted Sep 28, 2010, 5:58 AM
Manikavelu VelayuthamPosted Sep 28, 2010, 5:53 AM
Namespace: System.Data.Linq
Assembly: System.Data.Linq (in System.Data.Linq.dll)
vipin sainiPosted Sep 28, 2010, 5:51 AM
Manikavelu VelayuthamPosted Sep 28, 2010, 5:40 AM
you need to convert it to datatable before assigning it to the datasource.
To convert use the above code.
vipin sainiPosted Sep 28, 2010, 5:36 AM
My code give this error on the position select new
StringReader sr = new StringReader(ab);
DataSet ds2 = new DataSet();
ds2.ReadXml(sr);
var ordersQuery = ds2.Tables[11].AsEnumerable();
var orderLinesQuery = ds2.Tables[12].AsEnumerable();
var employeeinfo = from p in ordersQuery
join c in orderLinesQuery
on p.Field<int>("TPA_Extensions_Id") equals c.Field<int>("TPA_Extensions_Id")
select new
{
TPA_Extensions_Id = p.Field<int>("TPA_Extensions_Id"),
BasicPropertyInfo_Id = p.Field<int>("BasicPropertyInfo_Id"),
RPH = c.Field<int>("RPH")
};
GridView1.DataSource = employeeinfo;
GridView1.DataBind();
Manikavelu VelayuthamPosted Sep 28, 2010, 5:26 AM
vipin sainiPosted Sep 28, 2010, 5:21 AM
StringReader sr = new StringReader("xmlstring");
DataSet ds2 = new DataSet();
ds2.ReadXml(sr);
then what will be
customers=ds2.Tables[11].AsEnumerable();
vipin sainiPosted Sep 28, 2010, 5:16 AM
Manikavelu VelayuthamPosted Sep 28, 2010, 5:13 AM
var custOrders =
customers.
Join(orders, c => c.CustomerID, o => o.CustomerID,
(c, o) => new { c.Name, o.OrderDate, o.Total }
);
var custOrders =
from c in customers
join o in orders on c.CustomerID equals o.CustomerID
select new { c.Name, o.OrderDate, o.Total };
vipin sainiPosted Sep 28, 2010, 5:07 AM
Manikavelu VelayuthamPosted Sep 28, 2010, 5:05 AM