private bool CreatePropertyControl() { List <ProductProperty> selectedProperties = ProductProperties.GetPropertiesByProductID(ProductID); List <ProductProperty> properties = ProductProperties.GetAllPropertyByCategoryIDList(CategoryIDList); if (properties.Count > 0) { foreach (ProductProperty property in properties) { Literal ltBegin = new Literal(); ltBegin.Text = "<li>"; this.phProperty.Controls.Add(ltBegin); //label Label lblText = new Label(); lblText.Text = property.PropertyName; this.phProperty.Controls.Add(lblText); //textbox TextBox txtValue = new TextBox(); txtValue.ID = GenerateID(property.PropertyID); foreach (ProductProperty p in selectedProperties) { if (p.PropertyID == property.PropertyID) { txtValue.Text = p.PropertyValue; break; } } this.phProperty.Controls.Add(txtValue); List <ProductCategory> subCategories = ProductCategories.GetCategoriesByPropertyID(property.PropertyID); if (subCategories.Count > 0) { //ddl DropDownList ddlSubCategory = new DropDownList(); ddlSubCategory.Items.Add(new ListItem("请选择", "0")); foreach (ProductCategory category in subCategories) { ddlSubCategory.Items.Add(new ListItem(category.CategoryName, category.CategoryName.ToString())); } ddlSubCategory.Attributes.Add("onchange", "changeProperty(this)"); this.phProperty.Controls.Add(ddlSubCategory); } Literal ltEnd = new Literal(); ltEnd.Text = "</li>"; this.phProperty.Controls.Add(ltEnd); } return(true); } else { return(false); } }
public List <ProductProperty> GetProperties() { List <ProductProperty> properties = ProductProperties.GetAllPropertyByCategoryIDList(CategoryIDList); if (properties.Count > 0) { foreach (ProductProperty property in properties) { TextBox txtValue = this.FindControl(GenerateID(property.PropertyID)) as TextBox; if (txtValue != null) { property.PropertyValue = txtValue.Text.Trim(); } } } return(properties); }
List <ProductProperty> GetProperties() { return(ProductProperties.GetAllPropertyByCategoryIDList(GetCategoryIds())); }