// Create dropdownlist for product attributes
DropDownList dropdown = new DropDownList();
// Below region creates the dropdown menu which contains the
// items variations for the user to chose from
#region MatrixAttributesNew
public virtual string MatrixAttributesNew(int itemCounter, string itemCode, string itemType, string align)
{
Panel DivHolder = new Panel();
DivHolder.CssClass = "productchoice";
StringBuilder output = new StringBuilder();
string alignBreak = " ";
if (align.ToLowerInvariant().Equals("vertical") || align.ToLowerInvariant().Equals("v"))
{
alignBreak = " ";
}
Dictionary matrixAttributesByCode = new Dictionary();
using (IDataReader reader = DB.GetRS("exec aspdnsf_GetMatrixGroupAttributes @ItemCode = {0}", DB.SQuote(itemCode)))
{
while (reader.Read())
{
string attributeCode = DB.RSField(reader, "AttributeCode");
string attributeDescription = DB.RSField(reader, "AttributeDescription");
string attributeValueCode = DB.RSField(reader, "AttributeValueCode");
string attributeValueDescription = DB.RSField(reader, "AttributeValueDescription");
MatrixAttribute currentAttribute = null;
if (!matrixAttributesByCode.ContainsKey(attributeCode))
{
currentAttribute = new MatrixAttribute(attributeCode);
currentAttribute.AttributeCode = attributeCode;
currentAttribute.AttributeDescription = attributeDescription;
matrixAttributesByCode.Add(attributeCode, currentAttribute);
}
currentAttribute = matrixAttributesByCode[attributeCode];
currentAttribute.Values.Add(new MatrixAttributeValue(attributeValueCode, attributeValueDescription));
}
}
output.AppendFormat("", itemCounter);
output.AppendFormat("", itemCounter);
int ctr = 1;
foreach (string attributeCodeAsKey in matrixAttributesByCode.Keys)
{
MatrixAttribute currentAttribute = matrixAttributesByCode[attributeCodeAsKey];
dropdown.ID = "MatrixAttribute_" + itemCounter + "_" + ctr;
// select header
ListItem list = new ListItem();
list.Value = currentAttribute.AttributeCode;
list.Text = AppLogic.GetString("is_showproduct.aspx.54", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + " " + currentAttribute.AttributeDescription;
dropdown.Items.Add(list);
ListItemCollection listoptions = new ListItemCollection();
foreach (MatrixAttributeValue value in currentAttribute.Values)
{
ListItem listproducts = new ListItem();
listproducts.Value = Security.UrlEncode(value.AttributeValue);
listproducts.Text = Security.HtmlEncode(value.AttributeValueDescription);
listoptions.Add(listproducts);
dropdown.Items.Add(listproducts);
}
DivHolder.Controls.Add(dropdown);
ctr++;
}
StringWriter sw = new StringWriter(output);
HtmlTextWriter writer = new HtmlTextWriter(sw);
DivHolder.RenderControl(writer);
return output.ToString();
}
#endregion
// this region creates the addtocart button and the hidden input which needs editing
#region DisplayAddToCartFormNew
HtmlGenericControl myHiddenField = new HtmlGenericControl("input");
public void text_update(object sender, EventArgs e)
{
int position = dropdown.SelectedIndex + 1;
myHiddenField.Attributes.Clear();
myHiddenField.Attributes.Add("type", "hidden");
myHiddenField.Attributes.Add("name", "ProductID");
myHiddenField.ID = "ProductID_" + position;
myHiddenField.Attributes.Add("value", "" + position);
}
public string DisplayAddToCartFormNew(int itemCounter, string itemCode, string itemType, string align)
{
ItemWebOption settings = ItemWebOption.GetWebOption(itemCode);
//Check for wholesale parameter.
StringBuilder output = new StringBuilder();
string alignBreak = " ";
if (align.ToLowerInvariant().Equals("vertical") || align.ToLowerInvariant().Equals("v"))
{
alignBreak = " ";
}
string action = "addtocart.aspx?returnurl=" + HttpContext.Current.Server.UrlEncode(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
output.AppendLine();
// by default let's make this invisible
output.AppendFormat("\n");
return output.ToString();
}
#endregion
|