⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.aspx.cs

📁 网开商城系统网开商城系统网开商城系统网开商城系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Index : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            binder();

        }
    }
    public void binder()
    {  /*方法一传引用参数
        DataSet ds = new DataSet();
        Product pr = new Product();
        pr.Gettypeproduct("select top 4 * from Product where Hot='热卖'order by id desc", null, ref ds,"Product", 0);
        this.HotProduct.DataSource = ds.Tables[0].DefaultView;
        this.HotProduct.DataBind();
        DataSet ds1 = new DataSet();
        pr.Gettypeproduct("select top 4 * from Product where Jipin='精品'order by id desc", null, ref ds1,"Product", 0);
        this.Jipinproduct.DataSource = ds1.Tables[0].DefaultView;
        this.Jipinproduct.DataBind();
        DataSet ds2 = new DataSet();
        pr.Gettypeproduct("select top 4 * from Product where Tejia='特价'order by id desc", null, ref ds2,"Product", 0);
        this.Tejiaproduct.DataSource = ds2.Tables[0].DefaultView;
        this.Tejiaproduct.DataBind();*/
        //存储过程传递参数
        Product getfour = new Product();
        this.HotProduct.DataSource = getfour.GetTypeFour(1).DefaultView;
        this.HotProduct.DataBind();
        this.Jipinproduct.DataSource = getfour.GetTypeFour(2).DefaultView;
        this.Jipinproduct.DataBind();
        this.Tejiaproduct.DataSource = getfour.GetTypeFour(3).DefaultView;
        this.Tejiaproduct.DataBind();
        
    }

    protected void HotProduct_ItemCommand(object source, DataListCommandEventArgs e)
    {   if (e.CommandName == "buy")
        {   Session["id"] = ((Label)e.Item.FindControl("id")).Text;//商品编号
            Session["Proname"] = ((Label)e.Item.FindControl("Proname")).Text;//商品名称
            Session["MemberPrice"] = ((Label)e.Item.FindControl("MemberPrice")).Text;//商品单价
            Response.Redirect("buy.aspx");
        }
    }
    protected void Jipinproduct_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "buy")
        {
            Session["id"] = ((Label)e.Item.FindControl("id")).Text;//商品编号
            Session["Proname"] = ((Label)e.Item.FindControl("Proname")).Text;//商品名称
            Session["MemberPrice"] = ((Label)e.Item.FindControl("MemberPrice")).Text;//商品单价
            Response.Redirect("buy.aspx");
        }
    }
    protected void Tejiaproduct_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "buy")
        {
            Session["id"] = ((Label)e.Item.FindControl("id")).Text;//商品编号
            Session["Proname"] = ((Label)e.Item.FindControl("Proname")).Text;//商品名称
            Session["MemberPrice"] = ((Label)e.Item.FindControl("MemberPrice")).Text;//商品单价
            Response.Redirect("buy.aspx");
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -