protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Populate States/Provinces dropdown list StateProvince sp = new StateProvince(); List<StateProvince> states = sp.GetAllStatesProvinces(); DropDownListStateProvince.DataSource = states; DropDownListStateProvince.DataTextField = "Name"; DropDownListStateProvince.DataValueField = "StateProvinceID"; DropDownListStateProvince.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Obtain User ID from query string int userid = Convert.ToInt32(Request.QueryString["userid"]); //Get User by its code User user = new User(); user.GetUserByID(userid); //Populate States/Provinces dropdown list StateProvince sp = new StateProvince(); List<StateProvince> states = sp.GetAllStatesProvinces(); DropDownListStateProvince.DataSource = states; DropDownListStateProvince.DataTextField = "Name"; DropDownListStateProvince.DataValueField = "StateProvinceID"; DropDownListStateProvince.DataBind(); //Put user details into fields LabelUserID.Text = Request.QueryString["userid"].ToString(); TextBoxUsername.Text = Convert.ToString(user.Username); TextBoxPassword.Text = Convert.ToString(user.Password); TextBoxSalutation.Text = Convert.ToString(user.Salutation); TextBoxFirstName.Text = Convert.ToString(user.FirstName); TextBoxLastName.Text = Convert.ToString(user.LastName); TextBoxAddress1.Text = Convert.ToString(user.Address1); TextBoxAddress2.Text = Convert.ToString(user.Address2); TextBoxCity.Text = Convert.ToString(user.City); DropDownListStateProvince.SelectedValue = Convert.ToString(user.StateProvinceID); TextBoxZipPostalCode.Text = Convert.ToString(user.ZipCodePostal); TextBoxEmail.Text = Convert.ToString(user.Email); CheckBoxIsReceiveNewsletters.Checked = Convert.ToBoolean(user.IsReceiveNewsletters); LabelCreated.Text = Convert.ToDateTime(user.Created).ToShortDateString(); if (Convert.ToDateTime(user.Modified) > DateTime.MinValue) { LabelModified.Text = Convert.ToDateTime(user.Modified).ToShortDateString(); } else { LabelModified.Text = "N/A"; } } }
protected void DataListCheckout_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var item = e.Item.DataItem as DataRowView; if (item != null) { //Set the checkbox value attribute var chk = e.Item.FindControl("CheckBoxUseUserAddress") as CheckBox; if (chk != null) { chk.InputAttributes.Add("value", item["Prodcd"].ToString()); } //Set the dropdownlist datasource DropDownList spDDL = e.Item.FindControl("dropStateProv") as DropDownList; StateProvince sp = new StateProvince(); List<StateProvince> states = sp.GetAllStatesProvinces(); spDDL.DataSource = states; spDDL.DataTextField = "Name"; spDDL.DataValueField = "StateProvinceID"; spDDL.DataBind(); //Get all ProductDeliveryType objects for this prodcd ProductDeliveryType pdt = new ProductDeliveryType(); List<ProductDeliveryType> pdtypes = pdt.GetAllProductDeliveryTypesByProdCode(item["Prodcd"].ToString()); //For each ProductDeliveryType, add its associated DeliveryType object to the list List<DeliveryType> dTypes = new List<DeliveryType>(); foreach (ProductDeliveryType pdtype in pdtypes) { DeliveryType delType = new DeliveryType(); delType.GetDeliveryTypeByID(pdtype.DeliveryTypeID); dTypes.Add(delType); } //Assign list of DeliveryType to data list DropDownList delTypesDDL = e.Item.FindControl("DropDownListDeliveryType") as DropDownList; delTypesDDL.DataSource = dTypes; delTypesDDL.DataTextField = "Name"; delTypesDDL.DataValueField = "DeliveryTypeID"; delTypesDDL.DataBind(); } } }
private void reloadGridView() { if (DropDownListDBTables.SelectedValue == "Administrators") { //Get all objects Administrator obj = new Administrator(); List<Administrator> list = obj.GetAllAdministrators(false); //Fill a rendered object list List<RenderAdministrator> renderedList = new List<RenderAdministrator>(); foreach (Administrator x in list) { renderedList.Add(new RenderAdministrator(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Audits") { //Get all objects Audit obj = new Audit(); List<Audit> list = obj.GetAllAudits(); //Fill a rendered object list List<RenderAudit> renderedList = new List<RenderAudit>(); foreach (Audit x in list) { renderedList.Add(new RenderAudit(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "AuditTypes") { //Get all objects AuditType obj = new AuditType(); List<AuditType> list = obj.GetAllAuditTypes(); //Fill a rendered object list List<RenderAuditType> renderedList = new List<RenderAuditType>(); foreach (AuditType x in list) { renderedList.Add(new RenderAuditType(x)); } GridViewDBTable.DataSource = renderedList; } if (DropDownListDBTables.SelectedValue == "Categories") { //Get all objects Category obj = new Category(); List<Category> list = obj.GetAllCategories(false); //Fill a rendered object list List<RenderCategory> renderedList = new List<RenderCategory>(); foreach (Category x in list) { renderedList.Add(new RenderCategory(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Configurations") { //Get all objects Configuration obj = new Configuration(); List<Configuration> list = obj.GetAllConfigurations(); //Fill a rendered object list List<RenderConfiguration> renderedList = new List<RenderConfiguration>(); foreach (Configuration x in list) { renderedList.Add(new RenderConfiguration(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "DeliveryType") { //Get all objects DeliveryType obj = new DeliveryType(); List<DeliveryType> list = obj.GetAllDeliveryTypes(); //Fill a rendered object list List<RenderDeliveryType> renderedList = new List<RenderDeliveryType>(); foreach (DeliveryType x in list) { renderedList.Add(new RenderDeliveryType(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "LangLabels") { //Get all objects LangLabel obj = new LangLabel(); List<LangLabel> list = obj.GetAllLangLabels(); //Fill a rendered object list List<RenderLangLabel> renderedList = new List<RenderLangLabel>(); foreach (LangLabel x in list) { renderedList.Add(new RenderLangLabel(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "OrderItems") { //Get all objects OrderItem obj = new OrderItem(); List<OrderItem> list = obj.GetAllOrderItems(); //Fill a rendered object list List<RenderOrderItem> renderedList = new List<RenderOrderItem>(); foreach (OrderItem x in list) { renderedList.Add(new RenderOrderItem(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Orders") { //Get all objects Order obj = new Order(); List<Order> list = obj.GetAllOrders(); //Fill a rendered object list List<RenderOrder> renderedList = new List<RenderOrder>(); foreach (Order x in list) { renderedList.Add(new RenderOrder(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "ProductDeliveryTypes") { //Get all objects ProductDeliveryType obj = new ProductDeliveryType(); List<ProductDeliveryType> list = obj.GetAllProductDeliveryTypes(); //Fill a rendered object list List<RenderProductDeliveryType> renderedList = new List<RenderProductDeliveryType>(); foreach (ProductDeliveryType x in list) { renderedList.Add(new RenderProductDeliveryType(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Products") { //Get all objects Product obj = new Product(); List<Product> list = obj.GetAllProducts(false); //Fill a rendered object list List<RenderProduct> renderedList = new List<RenderProduct>(); foreach(Product x in list) { renderedList.Add(new RenderProduct(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "StatesProvinces") { //Get all objects StateProvince obj = new StateProvince(); List<StateProvince> list = obj.GetAllStatesProvinces(); //Fill a rendered object list List<RenderStateProvince> renderedList = new List<RenderStateProvince>(); foreach (StateProvince x in list) { renderedList.Add(new RenderStateProvince(x)); } GridViewDBTable.DataSource = renderedList; } else if (DropDownListDBTables.SelectedValue == "Users") { //Get all objects User obj = new User(); List<User> list = obj.GetAllUsers(); //Fill a rendered object list List<RenderUser> renderedList = new List<RenderUser>(); foreach (User x in list) { renderedList.Add(new RenderUser(x)); } GridViewDBTable.DataSource = renderedList; } //Databind the new datasource obtained above GridViewDBTable.DataBind(); }
protected void DataListCheckout_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { var item = e.Item.DataItem as CheckoutItem; if (item != null) { //Set the checkbox value attribute var chk = e.Item.FindControl("CheckBoxUseUserAddress") as CheckBox; if (chk != null) { chk.InputAttributes.Add("value", item.Prodcd.ToString()); } //Set the dropdownlist datasource DropDownList spDDL = e.Item.FindControl("dropStateProv") as DropDownList; StateProvince sp = new StateProvince(); List<StateProvince> states = sp.GetAllStatesProvinces(); spDDL.DataSource = states; spDDL.DataTextField = "Name"; spDDL.DataValueField = "StateProvinceID"; spDDL.DataBind(); } } }