0
DataTable dt = try.Query(" select Rooms.RoomId, Rooms.RoomType From Rooms INNER JOIN Reservations ON ( Rooms.RoomId = Reservations.RoomId ) AND GETDATE() BETWEEN Reservations.CheckInDate AND Reservations.CheckOutDate ORDER BY Rooms.RoomType");
        if (dt.Rows.Count > 0)
        {
            LblMessage.Text = " No Room Available";
        }
        else 
        {
            DataTable dt1 = try.Query( "Select  Rooms.RoomType, Rooms.PricePerNight From Rooms INNER JOIN Reservations ON (Rooms.RoomId != Reservations.Roomid) ORDER BY Rooms.Roomtype");

        if (dt1.Rows.Count > 0)
        {
            GridResult.DataSource = dt1;
            GridResult.DataBind();
        }
        else
        {
            LblMessage.Text = "No Rooms Availble";
        }

当我搜索时,我没有得到任何可用的房间“没有可用的房间”将会出现,我有这么多房间可用table Rooms rooms.roomid 它们显示那些在预订中找不到但在网格视图中的房间表中的项目的结果..仅此而已

谢谢请帮帮我

4

1 回答 1

2

我认为第一个条件是错误的。代码应该是

DataTable dt = try.Query("YOUR QUERY");
if (dt.Rows.Count > 0) {
   // Grid Bind Code
}
else {
   LblMessage.Text = " No Room Available";
}

希望这会有所帮助!

于 2013-07-12T16:25:30.637 回答