0
日付付きのユーザー入力に基づいてXMLファイルからデータを取得したいと思います。私は、xmlファイルの日付とユーザーの入力日付を比較し、xmlファイルの日付よりも大きい場合は、それを取得する必要があります。私のlinqクエリは、このような事前の感謝のように見えます。linqからxmlへの日付の操作
XDocument xmlDoc = XDocument.Load(Server.MapPath("xml/data1.xml"));
var hotels = from hotel in xmlDoc.Descendants("Table")
where Double.Parse(pplTextBox.Text) <= Double.Parse(hotel.Element("NO_OF_PEOPLE").Value) &&
DateTime.Parse(DateTextFrom.Text) > DateTime.Parse(hotel.Element("DATE_TO").Value)
select new
{
RoomCost = hotel.Element("ROOM_COST").Value,
RoomType = hotel.Element("ROOM_TYPE").Value,
HotelName = hotel.Element("HOTEL_NAME").Value,
NoOfPeople = hotel.Element("NO_OF_PEOPLE").Value,
Smoking = hotel.Element("SMOKING").Value,
Restaurant = hotel.Element("RESTAURANT").Value,
//Location = hotel.Element("HOTEL_AREA").Value,
//AvailableDate = hotel.Element("DATE_TO").Value
};
GridView1.DataSource = hotels.ToList();
GridView1.DataBind();
はい - 問題は何ですか?すでにXLINQクエリでDateをチェックしているようです。それからあなたの質問は何ですか? –
ユーザエンドから日付を選択したとき、およびチェックのためにチェックの空きが押されたときにエラーが発生しました。日時解析エラーが発生します。文字列が有効なDateTimeとして認識されませんでした。 – user161314
ユーザーは何を入力しますか?何の文字列ですか? Linq-To-XMLとはまったく関係のない文字列からDateTimeへの変換の問題はおそらく実際は....... –