index.aspx.cs

来自「网开商城系统网开商城系统网开商城系统网开商城系统」· CS 代码 · 共 78 行

CS
78
字号
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 + =
减小字号Ctrl + -
显示快捷键?