private void grdProducts_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow) { System.Web.UI.WebControls.Literal literal = (System.Web.UI.WebControls.Literal)e.Row.FindControl("litMainCategory"); literal.Text = "-"; object obj2 = System.Web.UI.DataBinder.Eval(e.Row.DataItem, "CategoryId"); if (obj2 != null && obj2 != System.DBNull.Value) { literal.Text = CatalogHelper.GetFullCategory((int)obj2); } ProductCategoriesDropDownList list = (ProductCategoriesDropDownList)e.Row.FindControl("dropAddToCategories"); list.DataBind(); System.Web.UI.WebControls.Literal literal2 = (System.Web.UI.WebControls.Literal)e.Row.FindControl("litExtendCategory"); literal2.Text = "-"; object obj3 = System.Web.UI.DataBinder.Eval(e.Row.DataItem, "ExtendCategoryPath"); if (obj3 != null && obj3 != System.DBNull.Value) { string s = (string)obj3; if (s.Length > 0) { s = s.Substring(0, s.Length - 1); if (s.Contains("|")) { s = s.Substring(s.LastIndexOf('|') + 1); } literal2.Text = CatalogHelper.GetFullCategory(int.Parse(s)); list.SelectedValue = new int?(int.Parse(s)); } } } }
private void grdProducts_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow) { ProductCategoriesDropDownList list = (ProductCategoriesDropDownList)e.Row.FindControl("dropAddToCategories"); list.SelectedIndexChanged += new System.EventHandler(this.dropAddToCategories_SelectedIndexChanged); } }
private void dropAddToCategories_SelectedIndexChanged(object sender, System.EventArgs e) { ProductCategoriesDropDownList productCategoriesDropDownList = (ProductCategoriesDropDownList)sender; System.Web.UI.WebControls.GridViewRow gridViewRow = (System.Web.UI.WebControls.GridViewRow)productCategoriesDropDownList.NamingContainer; if (productCategoriesDropDownList.SelectedValue.HasValue) { CatalogHelper.SetProductExtendCategory((int)this.grdProducts.DataKeys[gridViewRow.RowIndex].Value, CatalogHelper.GetCategory(productCategoriesDropDownList.SelectedValue.Value).Path + "|"); this.ReBind(false); return; } CatalogHelper.SetProductExtendCategory((int)this.grdProducts.DataKeys[gridViewRow.RowIndex].Value, null); this.ReBind(false); }
private void dropAddToCategories_SelectedIndexChanged(object sender, EventArgs e) { ProductCategoriesDropDownList list = (ProductCategoriesDropDownList)sender; GridViewRow namingContainer = (GridViewRow)list.NamingContainer; if (list.SelectedValue.HasValue) { CatalogHelper.SetProductExtendCategory((int)this.grdProducts.DataKeys[namingContainer.RowIndex].Value, CatalogHelper.GetCategory(list.SelectedValue.Value).Path + "|"); this.ReBind(false); } else { CatalogHelper.SetProductExtendCategory((int)this.grdProducts.DataKeys[namingContainer.RowIndex].Value, null); this.ReBind(false); } }