绑定
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ShopNum1.MultiBaseWebControl;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using ShopNum1.Factory;
using ShopNum1.BusinessLogic;
using ShopNum1.Common;
namespace ShopNum1.WebControl
{
[ParseChildren(true)]
public class ProductCategoryForList: BaseWebControl
{
/// <summary>
/// 品牌列表
/// </summary>
string skinFilename = "ProductCategoryForList.ascx"; // 指定默认皮肤样式
Repeater RepeaterBrand;
HiddenField HiddenFieldCode;
Label LabelProductCount;
Repeater RepeaterBrand2;
HiddenField HiddenFiledCode2;
Label LableBProductCount;
public string Code = string.Empty;
public ProductCategoryForList()
{
if (SkinFilename == null)
SkinFilename = skinFilename;
}
protected override void InitializeSkin(System.Web.UI.Control skin)
{
RepeaterBrand = (Repeater)skin.FindControl("RepeaterBrand");
RepeaterBrand.ItemDataBound += new RepeaterItemEventHandler(RepeaterBrand_ItemDataBound);
Code = this.Page.Request.QueryString["code"] == null ? "0" : this.Page.Request.QueryString["code"];
RepeaterBrand2 = (Repeater)skin.FindControl("RepeaterBrand2");
RepeaterBrand2.ItemDataBound += new RepeaterItemEventHandler(RepeaterBrand2_ItemDataBound);
if (!Page.IsPostBack){}
BindData();
}
void RepeaterBrand_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
HiddenFieldCode = (HiddenField)e.Item.FindControl("HiddenFieldCode");
LabelProductCount = (Label)e.Item.FindControl("LabelProductCount");
ShopNum1_ProuductChecked_Action productAction = (ShopNum1_ProuductChecked_Action)LogicFactory.CreateShopNum1_ProuductChecked_Action();
DataTable dataTable1 = productAction.GetproductCount(HiddenFieldCode.Value);
if (null != dataTable1 && dataTable1.Rows.Count > 0)
{
LabelProductCount.Text = dataTable1.Rows[0][0].ToString();
}
else {
LabelProductCount.Text = "0";
}
// string code = dt.Rows[i][code];
}
void RepeaterBrand2_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
HiddenFiledCode2 = (HiddenField)e.Item.FindControl("HiddenFiledCode2");
LableBProductCount = (Label)e.Item.FindControl("LableBProductCount");
ShopNum1_ProuductChecked_Action productAction = (ShopNum1_ProuductChecked_Action)LogicFactory.CreateShopNum1_ProuductChecked_Action();
DataTable dt = productAction.GetBProductCount(HiddenFiledCode2.Value);
if (null != dt && dt.Rows.Count > 0)
{
LableBProductCount.Text = dt.Rows.Count.ToString();
}
else
{
LableBProductCount.Text = "0";
}
}
private void BindData()
{
//按分类选择
ShopNum1_ProuductChecked_Action productAction = (ShopNum1_ProuductChecked_Action)LogicFactory.CreateShopNum1_ProuductChecked_Action();
DataTable dataTable1 = productAction.GetproductName(Code);
RepeaterBrand.DataSource = dataTable1.DefaultView;
RepeaterBrand.DataBind();
//品牌
ShopNum1_ProuductChecked_Action BrandAction = (ShopNum1_ProuductChecked_Action)LogicFactory.CreateShopNum1_ProuductChecked_Action();
DataTable dt = BrandAction.GetBrandName(Code);
RepeaterBrand2.DataSource = dt.DefaultView;
RepeaterBrand2.DataBind();
}
/// <summary>
/// 页面显示数目
/// </summary>
public string ShowCount { get; set; }
}
}