Page 1 of 1

Price in Kit Items Dropdown

Posted: Tue Aug 19, 2008 10:40 pm
by boycec
Is there a way to make the dropdown for a kit item not show the ($0.00)?

This was asked a while back in this thread: viewtopic.php?f=44&t=5969&p=24032&hilit ... ice#p24032

I have searched but I haven't found the answer

Re: Price in Kit Items Dropdown

Posted: Sun Aug 24, 2008 11:24 pm
by AbleMods
This revision is for AC7 Final. It will work on all the multi-select controls of a kit.

Edit your ~/App_Code/ProductHelper.cs file. Find the BuildKitOptions function and replace just that function with this code:

Code: Select all

    public static List<int> BuildKitOptions(Product product, PlaceHolder phOptions)
    {
        List<int> selectedChoices = new List<int>();
        foreach (ProductKitComponent pkc in product.ProductKitComponents)
        {
            KitComponent component = pkc.KitComponent;
            if (component.InputType != KitInputType.IncludedHidden && component.KitProducts.Count > 0)
            {
                // CREATE A LABEL FOR THE ATTRIBUTE
                phOptions.Controls.Add(new LiteralControl("<tr><th class=\"rowHeader\">" + component.Name + ":</th>"));
                // ADD THE CONTROL TO THE PLACEHOLDER
                phOptions.Controls.Add(new LiteralControl("<td align=\"left\">"));
                WebControl o = component.GetControl();
                if (o != null)
                {
                    Type oType = o.GetType();
                    if (oType.Equals(typeof(RadioButtonList)))
                    {
                        ((RadioButtonList)o).AutoPostBack = true;
                        for (int i = 0; i < ((RadioButtonList)o).Items.Count; i++)
                        {
                            ((RadioButtonList)o).Items[i].Text = ((RadioButtonList)o).Items[i].Text.Replace(" - ($0.00)", "");
                        }
                    }
                    else if (oType.Equals(typeof(DropDownList)))
                    {
                        ((DropDownList)o).AutoPostBack = true;
                        for (int i = 0; i < ((DropDownList)o).Items.Count; i++)
                        {
                            ((DropDownList)o).Items[i].Text = ((DropDownList)o).Items[i].Text.Replace(" - ($0.00)", "");
                        }
                    }
                    else if (oType.Equals(typeof(CheckBoxList)))
                    {
                        ((CheckBoxList)o).AutoPostBack = true;
                        for (int i = 0; i < ((CheckBoxList)o).Items.Count; i++)
                        {
                            ((CheckBoxList)o).Items[i].Text = ((CheckBoxList)o).Items[i].Text.Replace(" - ($0.00)", "");
                        }
                    }
                    phOptions.Controls.Add(o);
                    // SEE WHETHER A VALID VALUE FOR THIS FIELD IS PRESENT IN FORM POST
                    List<int> theseOptions = component.GetControlValue(o);
                    selectedChoices.AddRange(theseOptions);
                }
                phOptions.Controls.Add(new LiteralControl("</td></tr>"));
            }
        }
        return selectedChoices;
    }

Re: Price in Kit Items Dropdown

Posted: Mon Aug 25, 2008 9:24 pm
by boycec
That makes sense, I will give it a try.

Thanks