我需要将LINQ查询绑定到gridview的行。我正在试图创建一个像expedia中的矩阵那样的表,其中不停地在不同的行上停止和停止两次。我不太确定如何将查询绑定到gridview行。我感谢您的帮助。gridview行绑定到linq查询
var imgquery = from f in XElement.Load(MapPath("flightdata3.xml")).Elements("flight")
orderby Convert.ToInt32(f.Element("price").Value)
select new
{
ImagePath = (string)f.Element("airlineimageurl").Value
};
//query for gvMatrix where numberofstops=0
var numstops0query = from f in XElement.Load(MapPath("flightdata3.xml")).Elements("flight")
where Convert.ToInt32(f.Element("numberofstops").Value) == 0
orderby Convert.ToInt32(f.Element("price").Value)
select new
{
Price = "$" + (Int32)f.Element("price"),
ImagePath = (string)f.Element("airlineimageurl").Value
};
<asp:GridView ID="gvMatrix" runat="server">
</asp:GridView>
你的意思是说每一行都要绑定不同的数据集? – mehul9595 2011-05-01 14:59:33
请提供一些你想要做的代码示例 – Andre 2011-05-01 15:00:54
我的意思是每一行都会绑定到不同的查询。这是否有意义?每行都会有不同的条件,比如不停止= 0,不停止= 1,不停止= 2 – multiv123 2011-05-01 15:01:01