protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Set Dropdown ProductType_ddl.DataSource = ProductTypeHandler.GetProductTypes(); ProductType_ddl.DataTextField = "Name"; ProductType_ddl.DataValueField = "ID"; ProductType_ddl.SelectedIndex = -1; ProductType_ddl.DataBind(); ProductType_ddl.Items.Insert(0, new ListItem("--Select Product Type--", "-1")); //fill data in repeater RptProductListByType.DataSource = new ProductHandler().GetAllProduct(); RptProductListByType.DataBind(); } //jika admin if (Session.Keys.Count != 0) { if (Session["RoleID"].ToString().Equals("1")) { Btn_InsertNewProd.Visible = true; } } }
protected void ProductType_ddl_SelectedIndexChanged(object sender, EventArgs e) { int ProductTypeID = int.Parse(ProductType_ddl.SelectedValue); if (ProductTypeID == -1) { RptProductListByType.DataSource = new ProductHandler().GetAllProduct(); } else { RptProductListByType.DataSource = new ProductHandler().GetProductsByProductType(ProductTypeID); } RptProductListByType.DataBind(); }