protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List <Room> rooms = RoomDB.getRoomByOwner(Convert.ToInt32(Session["HotelID"])); //get the data from database if (rooms.Count != 0) //check the room data is not null { Session["room"] = rooms; //create a room session lblNoRoom.Visible = false; lvRoom.DataSource = rooms; lvRoom.DataBind(); } else { lblNoRoom.Visible = true; } //to disable past dates tbxCheckIn.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd"); tbxCheckOut.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd"); } }