using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Includes_Product_Left : System.Web.UI.UserControl
{
    BLL.Products pro = new BLL.Products();
    BLL.Type_1 t_1 = new BLL.Type_1();
    BLL.Type_2 t_2 = new BLL.Type_2();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitData();
            Bind();
        }
    }
    protected void Bind()
    {
        this.Rpt_Recommend.DataSource = pro.getrecommendedproductlist(9);
        this.Rpt_Recommend.DataBind();
        this.Rpt_new.DataSource = pro.productlisttop(9, 0, 0, "");
        this.Rpt_new.DataBind();
    }
    protected void Btn_search_Click(object sender, EventArgs e)
    {
        Response.Redirect("Product_List.aspx?type1=" + ddl1.SelectedValue + "&type2=" + ddl2.SelectedValue +
            "&key=" + this.valuekey.Value);
    }
    /// <summary>
    /// 绑定下拉框
    /// </summary>
    private void InitData()
    {
        DataTable dt = t_1.type_1list("");
        ddl1.Items.Add(new ListItem("全部大类", "0"));
        ddl2.Items.Add(new ListItem("全部小类", "0"));
        foreach (DataRow dr in dt.Rows)
        {
            ddl1.Items.Add(new ListItem(dr["TypeName"].ToString(), dr["TypeID_1"].ToString()));
        }
    }
    protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(ddl1.SelectedValue);
        DataTable dt = t_2.type_2list(id, "");
        ddl2.Items.Clear();
        ddl2.Items.Add(new ListItem("全部小类", "0"));
        foreach (DataRow dr in dt.Rows)
        {
            ddl2.Items.Add(new ListItem(dr["Type_2name"].ToString(), dr["TypeID2"].ToString()));
        }
    }
}
