protected void CategoryDropDownList_DataBound() { SubCategoryDropDownList.DataSource = new ProductSearchEngine.Business.Adapters.CategoryAdapter().GetSubCategories(int.Parse(CategoryDropDownList.SelectedValue)); SubCategoryDropDownList.DataTextField = "Name"; SubCategoryDropDownList.DataValueField = "Id"; SubCategoryDropDownList.DataBind(); }
protected void CategoryDropDownList_SelectedIndexChanged(object sender, EventArgs e) { SubCategoryDropDownList.DataSource = new ProductSearchEngine.Business.Adapters.CategoryAdapter().GetSubCategories(int.Parse(CategoryDropDownList.SelectedValue)); SubCategoryDropDownList.DataTextField = "Name"; SubCategoryDropDownList.DataValueField = "Id"; SubCategoryDropDownList.DataBind(); }
/// <summary> /// Set edit mode for edit comand /// Delete data from the database for delete comand /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdBudgetEstimation_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { ViewState["BudgetEstimationID"] = e.CommandArgument; BudgetEstimationBO objBudgetEstimation = new BudgetEstimationBO(); BudgetEstimationBLL objBudgetEstimationBLL = new BudgetEstimationBLL(); objBudgetEstimation = objBudgetEstimationBLL.GetBudgetEstimationByID(Convert.ToInt32(ViewState["BudgetEstimationID"])); if (objBudgetEstimation != null) { ValueTextBox.Text = UtilBO.CurrencyFormat(Convert.ToDecimal(objBudgetEstimation.ValueAmount)); HiddenFieldTotalValue.Value = (float.Parse(HiddenFieldTotalValue.Value) - float.Parse(objBudgetEstimation.ValueAmount)).ToString(); ValuePerTextBox.Text = objBudgetEstimation.ValueAmountper; BudgetEstimationIDTextBox.Text = objBudgetEstimation.BudgetEstimationID.ToString(); CategoryDropDownList.ClearSelection(); if (CategoryDropDownList.Items.FindByValue(objBudgetEstimation.CategoryID.ToString()) != null) { CategoryDropDownList.Items.FindByValue(objBudgetEstimation.CategoryID.ToString()).Selected = true; } getSubCatByCatID(); SubCategoryDropDownList.ClearSelection(); if (SubCategoryDropDownList.Items.FindByValue(objBudgetEstimation.SubCategoryID.ToString()) != null) { SubCategoryDropDownList.Items.FindByValue(objBudgetEstimation.SubCategoryID.ToString()).Selected = true; } AcountNumberTextBox.Text = objBudgetEstimation.AccountNo; } SetUpdateMode(true); } else if (e.CommandName == "DeleteRow") { string message = string.Empty; string budgetEstimationID = e.CommandArgument.ToString(); BudgetEstimationBLL objBudgetEstimationBLL = new BudgetEstimationBLL(); message = objBudgetEstimationBLL.DeleteBudgetEstimation(Convert.ToInt32(budgetEstimationID)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data deleted successfully"; } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } ClearDetails(); SetUpdateMode(false); BindEstCategories(); getToatlBudgetValue(); } }
private void LoadData() { CategoryDropDownList.DataSource = new ProductSearchEngine.Business.Adapters.CategoryAdapter().GetMainCategories(); CategoryDropDownList.DataTextField = "Name"; CategoryDropDownList.DataValueField = "Id"; CategoryDropDownList.DataBind(); BrandDropDownList.DataSource = new ProductSearchEngine.Business.Adapters.BrandAdapter().GetBrandList(); BrandDropDownList.DataTextField = "Name"; BrandDropDownList.DataValueField = "Id"; BrandDropDownList.DataBind(); CategoryDropDownList.SelectedIndex = 0; SubCategoryDropDownList.DataSource = new ProductSearchEngine.Business.Adapters.CategoryAdapter().GetSubCategories(int.Parse(CategoryDropDownList.SelectedValue)); SubCategoryDropDownList.DataTextField = "Name"; SubCategoryDropDownList.DataValueField = "Id"; SubCategoryDropDownList.DataBind(); SubmitButton.Click += new EventHandler(SubmitButton_Click); }
/// <summary> /// method to bind data to subcategory dropdownlist /// </summary> /// <param name="categoryID"></param> /// <param name="lastItemSelected"></param> protected void BindSubCategories(int categoryID, bool lastItemSelected) { BudgetEstimationBLL BudgetEstimationBLLobj = new BudgetEstimationBLL(); ListItem lstItem = new ListItem(SubCategoryDropDownList.Items[0].Text, SubCategoryDropDownList.Items[0].Value); SubCategoryDropDownList.Items.Clear(); SubCategoryDropDownList.DataSource = BudgetEstimationBLLobj.getSubCatByCatID(categoryID); SubCategoryDropDownList.DataTextField = "SubCategoryName"; SubCategoryDropDownList.DataValueField = "SubCategoryID"; SubCategoryDropDownList.DataBind(); SubCategoryDropDownList.Items.Insert(0, lstItem); if (lastItemSelected) { SubCategoryDropDownList.Items[SubCategoryDropDownList.Items.Count - 1].Selected = true; } else { SubCategoryDropDownList.SelectedIndex = 0; } }