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_Main_Left : System.Web.UI.UserControl
{
    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 (!this.IsPostBack)
        {
            this.Bind();
        }
    }
    private void Bind()
    {
        DataTable t_1table = t_1.toplist(1,5);//第二条到第五条记录.
        this.parent.DataSource = t_1table.DefaultView;
        this.parent.DataBind();
        //绑定top
        DataTable dt = t_1.toplist(1);
        this.top_parent.DataSource = dt.DefaultView;
        this.top_parent.DataBind();
    }
    /// <summary>
    /// 绑定下面四个
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void parent_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataList list = e.Item.FindControl("child") as DataList;
            DataRowView drv = e.Item.DataItem as DataRowView;
            DataTable table = t_2.type_2listtop(8,int.Parse(drv["typeid_1"].ToString()),"");
            list.DataSource = table.DefaultView;
            list.DataBind();
        }
    }
    /// <summary>
    /// 绑定top
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void top_parent_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DataList list = e.Item.FindControl("child") as DataList;
            DataRowView drv = e.Item.DataItem as DataRowView;
            DataTable table = t_2.type_2listtop(8, int.Parse(drv["typeid_1"].ToString()), "");
            list.DataSource = table.DefaultView;
            list.DataBind();
        }
    }
}
