protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { user_id = (int)Session["user_id"]; DBMgr_Jeff dbmJ = DBMgr_Jeff.getInstance(); linkBtnUser.Text = dbmJ.getUser(user_id); List <Reservation> reservations = dbmJ.getReservations(user_id); rptView.DataSource = reservations; rptView.DataBind(); //Add items to DropDown //for (int i = 0; i < hotels.Count; i++) //{ // ListItem newItem = new ListItem() // { // Value = hotels[i].r_id.ToString(), // Text = hotels[i].r_id + " / " + hotels[i].c_id // + " / " + hotels[i].h_name + " / " + hotels[i].r_type // + " / " + hotels[i].starting + " / " + hotels[i].ending // + " / " + hotels[i].quantity // + " / " + hotels[i].spDescription + " / " + hotels[i].spCost, // }; // rblist1.Items.Add(newItem); //} } }
//singleton pattern //a bad practice to connect to database public static DBMgr_Jeff getInstance() { if (dbInstance == null) { dbInstance = new DBMgr_Jeff(); } return(dbInstance); }
protected void Page_Load(object sender, EventArgs e) { HotelRoomQuantity hotel_room = (HotelRoomQuantity)HttpContext.Current.Session["hotel_room"]; lblSelectedRoom.Text = hotel_room.H_name + " / " + hotel_room.R_type; dbmJ = DBMgr_Jeff.getInstance(); user_id = (int)Session["user_id"]; }