private string[][] getAttributeValues(RepeaterItem typeItem) { HyperCatalog.Business.DAM.ResourceType type = resourceTypes[ddlResourceType.SelectedIndex]; string[][] attrs = new string[type.Attributes.Count][]; if (typeItem != null) { Repeater rptAttributes = (Repeater)typeItem.FindControl("rptAttributes"); if (rptAttributes != null) { for (int i = 0; i < rptAttributes.Items.Count; i++) { HyperCatalog.Business.DAM.VariantAttribute attrDef = type.Attributes.GetAttributeDefinition(i); TextBox txtAttribute = (TextBox)rptAttributes.Items[i].FindControl("txtAttribute"); DropDownList ddlAttribute = (DropDownList)rptAttributes.Items[i].FindControl("ddlAttribute"); if (attrDef != null && txtAttribute != null && ddlAttribute != null) { attrs[i] = new string[] { attrDef.Name, attrDef.UserDefined ? attrDef.PossibleValues.Count == 0 ? txtAttribute.Text : ddlAttribute.SelectedValue : null } } ; } } } return(attrs); }
protected void rptResourceTypes_ItemDataBound(object sender, RepeaterItemEventArgs e) { Repeater rptAttributes = (Repeater)e.Item.FindControl("rptAttributes"); HyperCatalog.Business.DAM.ResourceType dataItem = (HyperCatalog.Business.DAM.ResourceType)e.Item.DataItem; if (rptAttributes != null && dataItem != null) { HyperCatalog.Business.DAM.VariantAttributeSet attributes = dataItem.Attributes; rptAttributes.DataSource = attributes; rptAttributes.DataBind(); foreach (RepeaterItem item in rptAttributes.Items) { Label lblAutomatic = (Label)item.FindControl("lblAutomatic"); TextBox txtAttribute = (TextBox)item.FindControl("txtAttribute"); DropDownList ddlAttribute = (DropDownList)item.FindControl("ddlAttribute"); HyperCatalog.Business.DAM.VariantAttribute attrDef = attributes.GetAttributeDefinition(item.ItemIndex); if (attrDef != null) { lblAutomatic.Visible = !attrDef.UserDefined; string value = attributes[item.ItemIndex]; if (attrDef.UserDefined) { if (txtAttribute != null) { txtAttribute.Text = value; txtAttribute.Visible = attrDef.PossibleValues.Count == 0; } if (ddlAttribute != null) { ddlAttribute.DataSource = attrDef.PossibleValues; ddlAttribute.DataBind(); ddlAttribute.SelectedValue = value != null ? value : attrDef.DefaultValue; ddlAttribute.Visible = attrDef.PossibleValues.Count > 0; //attrValueList.Enabled = attrDef.PossibleValues.Count>1; } } } } } }