public void GetALLCategories() { CategoriesDropDownList.DataSource = _ItemSalesRepository.GetAllCategories(); CategoriesDropDownList.DataTextField = "Name"; CategoriesDropDownList.DataValueField = "Id"; CategoriesDropDownList.DataBind(); CategoriesDropDownList.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Select Categories", "0")); }
public void GetAllCategories() { CategoriesDropDownList.DataSource = _ProductSetupRepository.GetAllCategories(); CategoriesDropDownList.DataTextField = "Name"; CategoriesDropDownList.DataValueField = "Id"; CategoriesDropDownList.DataBind(); CategoriesDropDownList.Items.Insert(0, new ListItem("Select Category", "0")); }
public void GetAllCategories() { CategoriesDropDownList.DataSource = _PurchaseRepository.GetAllCategories(); CategoriesDropDownList.DataTextField = "Name"; CategoriesDropDownList.DataValueField = "Id"; CategoriesDropDownList.DataBind(); CategoriesDropDownList.Items.Insert(0, new ListItem("Chose Category", "0")); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // Read the connection string from Web.config string connectionString = ConfigurationManager.ConnectionStrings["RB_RecipeBook"].ConnectionString; using (SqlConnection conn = new SqlConnection(connectionString)) { try { // Get data about users from the database SqlDataAdapter adapterUsers = new SqlDataAdapter("SELECT idUser, UserName FROM RB_User", conn); DataTable storeTableUsers = new DataTable(); // table to store the sql command adapterUsers.Fill(storeTableUsers); // Populate dropdownlist SubmittedByDropDownList.DataSource = storeTableUsers; SubmittedByDropDownList.DataTextField = "UserName"; SubmittedByDropDownList.DataValueField = "idUser"; SubmittedByDropDownList.DataBind(); // Add extra item "All" SubmittedByDropDownList.Items.Insert(0, new ListItem("All Users")); // Get data about categories from the database SqlDataAdapter adapterCategories = new SqlDataAdapter("SELECT idCategory, CategoryName FROM RB_Category", conn); DataTable storeTableCategories = new DataTable(); // table to store the sql command adapterCategories.Fill(storeTableCategories); // Populate dropdownlist CategoriesDropDownList.DataSource = storeTableCategories; CategoriesDropDownList.DataTextField = "CategoryName"; CategoriesDropDownList.DataValueField = "idCategory"; CategoriesDropDownList.DataBind(); // Add extra item "All" CategoriesDropDownList.Items.Insert(0, new ListItem("All Categories")); // Get data about ingredients from the database SqlDataAdapter adapterIngredients = new SqlDataAdapter("SELECT idIngredient, IngredientName FROM RB_Ingredient", conn); DataTable storeTableIngredients = new DataTable(); // table to store the sql command adapterIngredients.Fill(storeTableIngredients); // Populate dropdownlist IngredientsDropDownList.DataSource = storeTableIngredients; IngredientsDropDownList.DataTextField = "IngredientName"; IngredientsDropDownList.DataValueField = "idIngredient"; IngredientsDropDownList.DataBind(); // Add extra item "All" IngredientsDropDownList.Items.Insert(0, new ListItem("All Ingredients")); } catch (Exception ex) { MessageLabel.Text = "ERROR: " + ex.Message; } } } }