private void BindVehicle() { try { Vehicle vehicle = Vehicle.GetVehicleByVehicleId(this.vehicleId); TextBoxType.Text = vehicle.Type; TextBoxModel.Text = vehicle.Model; TextBoxVehicleRegistration.Text = vehicle.Registration; TextBoxVINNumber.Text = vehicle.VINNumber; TextBoxTrackerReference.Text = vehicle.TrackerReference; TextBoxComment.Text = vehicle.Comment; DropDownListVehicleOwnership.ClearSelection(); DropDownListVehicleOwnership.Items.FindByValue(vehicle.VehicleOwnershipId.ToString()).Selected = true; DropDownListVehicleInsuranceBand.ClearSelection(); DropDownListVehicleInsuranceBand.Items.FindByValue(vehicle.VehicleInsuranceBandId.ToString()).Selected = true; } catch (System.Data.SqlClient.SqlException sqlEx) { for (int i = 0; i < sqlEx.Errors.Count; i++) { LabelError.Text += (sqlEx.Errors[i].Message + "<br />"); } PanelError.Visible = true; } catch (Exception exception) { LabelError.Text += (exception.Message + "<br />"); PanelError.Visible = true; } }
private void BindVehicleInsuranceBand() { DropDownListVehicleInsuranceBand.ClearSelection(); DropDownListVehicleInsuranceBand.DataSource = VehicleInsuranceBand.GetVehicleInsuranceBandList(); DropDownListVehicleInsuranceBand.DataTextField = "Description"; DropDownListVehicleInsuranceBand.DataValueField = "VehicleInsuranceBandId"; DropDownListVehicleInsuranceBand.DataBind(); DropDownListVehicleInsuranceBand.Items.Insert(0, new ListItem("Please select", "0")); }