protected void ButtonAdd_Click(object sender, EventArgs e) { RelationsCategoriesGoodsActions R_C_G_Actions = new RelationsCategoriesGoodsActions(); int SelectedCategoryID = TreeViewControl1.SelectedNodeID; LabelAddSuccess.Text = R_C_G_Actions.AddCategoriesToGoods(SelectedCategoryID, SelectedGoodsID); if (ViewState["categoriesGoodsList"] != null) { categoriesGoodsList = (List <Categories>)ViewState["categoriesGoodsList"]; CategoriesActions categoriesActions = new CategoriesActions(); categoriesGoodsList.Add(categoriesActions.FindCategory(SelectedCategoryID)); RepeaterGoodsCategories.DataSource = categoriesGoodsList; ViewState["categoriesGoodsList"] = categoriesGoodsList; } else { categoriesGoodsList = R_C_G_Actions.GetCategoriesForGoods(SelectedGoodsID); RepeaterGoodsCategories.DataSource = categoriesGoodsList; ViewState["categoriesGoodsList"] = categoriesGoodsList; } RepeaterGoodsCategories.DataBind(); PanelAddCategory.Enabled = false; }