我想顯示航空公司名稱下方的航空公司圖像。我在我的XML文件中爲airlineImage存儲了路徑。我將如何去使用LINQ在我的查詢中顯示圖像?使用LINQ查詢顯示圖像
這裏是我到目前爲止的代碼:
var query = from f in XElement.Load(MapPath("flightdata2.xml")).Elements("flight")
select new
{
Airline = (string)f.Element("airline"),
DepartureAirportSymbol = (string)f.Element("departureAirportSymbol"),
DepartTime = (string)f.Element("departureTime"),
DestinationAirportSymbol = (string)f.Element("destinationAirportSymbol"),
ArrivalTime = (string)f.Element("arrivalTime"),
Stops = (int)f.Element("numberOfStops"),
Duration = (string)f.Element("duration"),
Cabin = (string)f.Element("class"),
Price = "$" + (Int32)f.Element("price")
};
this.GridView1.DataSource = query;
this.GridView1.DataBind();
這聽起來好像你不應該這樣做,也許你的web應用程序首次加載xml文件時,可能會將xml處理成簡單的字典。 – IanNorton 2011-04-20 19:18:28
好吧,網格中的圖片列應該託管一些圖片控件,它會給出一個圖片文件的路徑來加載實際圖片。 我不認爲,Linq與它有任何關係。它所做的只是查詢信息。 – Andrei 2011-04-20 19:59:05