private void BindData() { CarBLL carBL = new CarBLL(connectionString); CarList.DataSource = carBL.GetCarInventory(); CarList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CarBLL bll = new CarBLL(connectionString); List <CarViewModel> cars = new List <CarViewModel>(bll.GetCarInventory()); foreach (var car in cars) { ddlRide.Items.Insert(cars.IndexOf(car), new ListItem(car.Name.ToString(), car.CarID.ToString())); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CarBLL entity = new CarBLL(connectionString); List <CarViewModel> CarList = new List <CarViewModel>(); List <string> CarNames = new List <string>(); CarList = entity.GetCarInventory(); foreach (CarViewModel Car in CarList) { CarNames.Add(Car.Name.ToString()); } RideDropDownList.DataSource = CarNames; RideDropDownList.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CarBLL carBL = new CarBLL(connectionString); ReportBLL reportBL = new ReportBLL(connectionString); ReportViewModel report = reportBL.GetReportById(Convert.ToInt32(Request.QueryString["ReportID"])); List <CarViewModel> cars = new List <CarViewModel>(carBL.GetCarInventory()); foreach (var car in cars) { ddlRide.Items.Insert(cars.IndexOf(car), new ListItem(car.Name.ToString(), car.CarID.ToString())); } tbIncidentDate.Text = report.DateOfIncident.ToString(); tbReportName.Text = report.ReportName.ToString(); tbDescription.Text = report.ReportDescription; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CarBLL entity = new CarBLL(connectionString); List <CarViewModel> CarList = new List <CarViewModel>(); List <string> CarNames = new List <string>(); CarList = entity.GetCarInventory(); foreach (CarViewModel Car in CarList) { CarNames.Add(Car.Name.ToString()); } RideDropDownList.DataSource = CarNames; RideDropDownList.DataBind(); ReportBLL bll = new ReportBLL(connectionString); ReportViewModel report = bll.GetReportById(Convert.ToInt32(Request.QueryString["ReportID"])); RideDropDownList.SelectedValue = GetCarName(report.CarID); DateOfIncident.Text = Convert.ToDateTime(report.DateOfIncident).ToString("yyyy-MM-dd"); ReportName.Text = report.ReportName; ReportDescription.Text = report.ReportDescription; } }
public string GetCarName(int carID) { CarBLL entity = new CarBLL(connectionString); return(entity.GetCarInventory().Where(x => x.CarID == carID).Select(x => x.Name).FirstOrDefault()); }