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 Admin_EditSelector_ProductAttributes : WebBlocks.AdministrativePage { public int SelectorID { get { return (ViewState["SelectorID"] == null ? 0 : (int)ViewState["SelectorID"]); } set { ViewState["SelectorID"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request["SelectorID"] != null) SelectorID = Int32.Parse(Request["SelectorID"]); BindData(); } } private void BindData() { DataTable dt = Database.Attributes_GetBySelectorID(SelectorID); gvSearchAttributes.DataSource = dt; gvSearchAttributes.DataBind(); dt = Database.Attributes_GetAllNotAssociatedToSelectorID(SelectorID); lstAttributes.DataSource = dt; lstAttributes.DataBind(); } protected void gvSearchAttributes_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "del") { int RowIndex = Int32.Parse((string)e.CommandArgument); int AttributeID = (int)gvSearchAttributes.DataKeys[RowIndex].Value; Database.AttributeSelectorMap_Delete(SelectorID, AttributeID); BindData(); } } protected void btnAdd_Click(object sender, EventArgs e) { foreach (ListItem li in lstAttributes.Items) { if (li.Selected) { int AttributeID = Int32.Parse(li.Value); Database.AttributeSelectorMap_Add(SelectorID, AttributeID); } } BindData(); } }