Add new product. How to make First Catagory to be selected by default.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
I had the same problem, here is what I have done :

1- Open
NopCommerceStore\Administration\Modules\ProductInfoAdd.ascx.cs

2- Search for
this.ddlTaxCategory.Items.Clear();
       line 72
3- You will find a foreach like this line 90 :

foreach (TaxCategory taxCategory in taxCategoryCollection)
            {
                ListItem item2 = new ListItem(taxCategory.Name, taxCategory.TaxCategoryId.ToString());
                this.ddlTaxCategory.Items.Add(item2);
            }


4- Add those lines after the foreach at line 81


            //Added by Mena Bassily
                this.ddlTaxCategory.Items[1].Selected = true;            
            //End of Added by Mena Bassily


Now go to Configuration - Tax - Tax Classes, Open the wanted TaxClass and give it Display Order = 1
13 years ago
Don't forget to add the commented lines as well in the ProductVariantInfo.ascx.cs


protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.FillDropDowns();
                this.BindData();
                //Added by Mena Bassily
                      this.ddlTaxCategory.Items[1].Selected = true;            //line 252
                //End of Added by Mena Bassily
            }
        }
13 years ago
Sorry about the last reply, it contains an error, the right way it to edit ProductVariantInfo.ascx.cs

and add :

                //Added by Mena Bassily
                      this.ddlTaxCategory.Items[1].Selected = true;            //line 252
                //End of Added by Mena Bassily


after :

this.ddlTaxCategory.Items.Clear();
            ListItem itemTaxCategory = new ListItem("---", "0");
            this.ddlTaxCategory.Items.Add(itemTaxCategory);
            var taxCategoryCollection = TaxCategoryManager.GetAllTaxCategories();
            foreach (TaxCategory taxCategory in taxCategoryCollection)
            {
                ListItem item2 = new ListItem(taxCategory.Name, taxCategory.TaxCategoryId.ToString());
                this.ddlTaxCategory.Items.Add(item2);
            }
13 years ago
Thanks mb. Like it
I hope it will be changed  for next version (all admin dropdown list)
13 years ago
I'm watching this post : https://www.nopcommerce.com/boards/t/4106/add-new-product-how-to-make-first-catagory-to-be-selected-by-default.aspx
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.