当前位置: 首页>>代码示例>>C#>>正文


C# ProductModel.GetAllProducts方法代码示例

本文整理汇总了C#中ProductModel.GetAllProducts方法的典型用法代码示例。如果您正苦于以下问题:C# ProductModel.GetAllProducts方法的具体用法?C# ProductModel.GetAllProducts怎么用?C# ProductModel.GetAllProducts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProductModel的用法示例。


在下文中一共展示了ProductModel.GetAllProducts方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FillPage

    private void FillPage()
    {
        //get a list of all products in DB
        ProductModel productModel = new ProductModel();
        List<Product> products = productModel.GetAllProducts();

        //make sure products exist in database
        if (products != null)
        {
            //create new Pannel with an ImageButton and 2 labels for each Product
            foreach (Product product in products)
            {
                Panel productPanel = new Panel();
                ImageButton imageButton = new ImageButton();
                Label lblName = new Label();
                Label lblPrice = new Label();

                //set ChildControls properties
                imageButton.ImageUrl = "~/Images/Products/" + product.Image;
                imageButton.CssClass = "productImage";
                imageButton.PostBackUrl = "~/Pages/Product.aspx?id=" + product.Id;

                lblName.Text = product.Name;
                lblName.CssClass = "productName";

                lblPrice.Text = product.Price + " лв.";
                lblPrice.CssClass = "productPrice";

                //Add child controls to pannel
                productPanel.Controls.Add(imageButton);
                productPanel.Controls.Add(new Literal { Text = "<br/>" });
                productPanel.Controls.Add(lblName);
                productPanel.Controls.Add(new Literal { Text = "<br/>" });
                productPanel.Controls.Add(lblPrice);

                //add dynamic panels to static parent panel
                pnlProducts.Controls.Add(productPanel);
            }
        }
        else 
        {
            //no products found
            pnlProducts.Controls.Add(new Literal { Text = "No products found!" });

        }
    }
开发者ID:apostolnikov,项目名称:NikovBikeOnlineStore,代码行数:46,代码来源:Index.aspx.cs

示例2: CreateList

    private List<Product> CreateList()
    {
        ProductModel productModel = new ProductModel();
        List<Product> products = new List<Product>();

        if (ddlList.SelectedItem.Value == "(All)" || ddlList.SelectedIndex < 1)
        {
            products = productModel.GetAllProducts();
        }//Get a list of all products in DB

        else
        {
            
            String ID = ddlList.SelectedItem.Value;
            int id = Convert.ToInt32(ID);
            products = productModel.GetProductByCategory(id);
        }

        return products;
    }
开发者ID:alicezhuwy,项目名称:Asp.net-webshop,代码行数:20,代码来源:WebShop.aspx.cs

示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        ProductModel model = new ProductModel();
        List<Product> products = model.GetAllProducts();

        if (products != null)
        {
            foreach (Product product in products)
            {
                Panel productPanel = new Panel();
                ImageButton imageButton = new ImageButton
                {
                    ImageUrl = "~/Images/Products/" + product.Image,
                    CssClass = "productImage",
                    PostBackUrl = string.Format("~/Pages/Product.aspx?id={0}", product.ID)
                };
                Label lblName = new Label
                {
                    Text = product.Name,
                    CssClass = "productName"
                };
                Label lblPrice = new Label
                {
                    Text = "£ " + product.Price,
                    CssClass = "productPrice"
                };

                productPanel.Controls.Add(imageButton);
                productPanel.Controls.Add(new Literal {Text = "<br/>"});
                productPanel.Controls.Add(lblName);
                productPanel.Controls.Add(new Literal {Text = "<br/>"});
                productPanel.Controls.Add(lblPrice);

                //Add dynamic controls to static control
                pnlProducts.Controls.Add(productPanel);
            }
        }
        else
            pnlProducts.Controls.Add(new Literal {Text = "No products found!"});
    }
开发者ID:henrypedersen77,项目名称:GarageManagerMaster,代码行数:40,代码来源:Index.aspx.cs

示例4: FillPage

    private void FillPage()
    {
        ProductModel productModel = new ProductModel();
        List<Product> products = productModel.GetAllProducts();

        if (products != null)
        {
            foreach (Product product in products)
            {
                Panel productPanel = new Panel();
                ImageButton imageButton = new ImageButton();
                Label lblName = new Label();
                Label lblPrice = new Label();

                imageButton.ImageUrl = "~/Images/Products/" + product.Image;
                imageButton.CssClass = "productImage";
                imageButton.PostBackUrl = "~/Pages/Product.aspx?id=" + product.Id;

                lblName.Text = product.Name;
                lblName.CssClass = "productName";

                lblPrice.Text = "$ " + product.Price;
                lblPrice.CssClass = "productPrice";

                productPanel.Controls.Add(imageButton);
                productPanel.Controls.Add(new Literal { Text = "<br />" });
                productPanel.Controls.Add(lblName);
                productPanel.Controls.Add(new Literal { Text = "<br />" });
                productPanel.Controls.Add(lblPrice);

                pnlProducts.Controls.Add(productPanel);

            }
        }
        else
        {
            pnlProducts.Controls.Add(new Literal { Text = "No products found" });
        }
    }
开发者ID:Rita124,项目名称:Candzoil2,代码行数:39,代码来源:Index.aspx.cs


注:本文中的ProductModel.GetAllProducts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。