Esempio n. 1
0
        private void LoadCategory()
        {
            string        conStr = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            SqlConnection conn   = new SqlConnection(conStr);
            string        query  = "select Category_ID, Category_Name from ProductCategory";
            SqlCommand    cmd    = new SqlCommand(query, conn);

            try
            {
                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                DropDownListProductCategory.DataTextField  = "Category_Name";
                DropDownListProductCategory.DataValueField = "Category_ID";
                DropDownListProductCategory.DataSource     = reader;
                DropDownListProductCategory.DataBind();
            }
            catch (Exception exc)
            {
                Response.Write(exc.ToString());
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 2
0
        public void LoadProductCategory()
        {
            List <ProductCategory> aProductCategories = aProductCategoryManager.LoadProductCategories();

            DropDownListProductCategory.DataSource     = aProductCategories;
            DropDownListProductCategory.DataValueField = "ProductCategoryName";
            DropDownListProductCategory.DataTextField  = "ProductCategoryName";
            DropDownListProductCategory.DataBind();
        }