コード例 #1
0
        void RenderButton(HtmlTextWriter writer)
        {
            DataTable brandsByCategoryId = ProductBrowser.GetBrandsByCategoryId(this.CategoryId);

            if ((brandsByCategoryId != null) && (brandsByCategoryId.Rows.Count > 0))
            {
                WebControl control = new WebControl(HtmlTextWriterTag.Label);
                control.Controls.Add(new LiteralControl("<span>品牌:</span>"));
                control.RenderControl(writer);
                WebControl control2 = new WebControl(HtmlTextWriterTag.A);
                control2.Controls.Add(new LiteralControl("全部"));
                control2.Attributes.Add("href", this.urlFormatForALL);
                if (this.Context.Request.RawUrl.IndexOf("brand") < 0)
                {
                    control2.Attributes.Add("class", this.AllCss);
                }
                control2.RenderControl(writer);
                foreach (DataRow row in brandsByCategoryId.Rows)
                {
                    WebControl control3 = new WebControl(HtmlTextWriterTag.A);
                    control3.Controls.Add(new LiteralControl(row["BrandName"].ToString()));
                    if (this.SelectedBrand == int.Parse(row["BrandId"].ToString()))
                    {
                        control3.Attributes.Add("class", this.SelectCss);
                    }
                    else
                    {
                        control3.Attributes.Add("href", this.urlFormat + row["BrandId"].ToString());
                    }
                    control3.RenderControl(writer);
                }
            }
        }