物联网工程实践


原价:

促销:

售量:30天内售出1000件,交易成功999件
评价:0条评价



尺码:S M L
颜色:黑色 白色

数量:


 

2、后台关键代码

Session

public partial class 展示 : System.Web.UI.Page {

public string imgUrl1; public string Name1; public string Price1; public string Number1;

protected void Page_Load(object sender, EventArgs e) { }

protected void Button1_Click(object sender, EventArgs e)

{

session1();

Response.Write(\购物车.aspx','_blank')\); // Response.Redirect(\购物车.aspx\ }

protected void Button2_Click(object sender, EventArgs e) {

session1(); }

protected void Button4_Click(object sender, EventArgs e) {

int n = Convert.ToInt32(num.Text); n++;

string s = Convert.ToString(n); num.Text = s; }

protected void Button3_Click(object sender, EventArgs e) {

int n = Convert.ToInt32(num.Text); n--;

string s = Convert.ToString(n); num.Text = s; }

public void session1() {

imgUrl1 = \商品1.jpg\; Name1 = \商品1\; Price1 = Label3.Text; Number1 = num.Text; Session[\] = imgUrl1; Session[\] = Name1; Session[\] = Price1; Session[\] = Number1; } } 购物车

protected void Button1_Click(object sender, EventArgs e) {

pr1 = Session[\].ToString(); pr2 = Session[\].ToString(); p1 = Convert.ToDouble(pr1); p2 = Convert.ToDouble(pr2); num1 = Session[\].ToString(); num2 = Session[\].ToString();

n1 = Convert.ToInt32(num1); n2 = Convert.ToInt32(num2); total = p1 * n1 + p2 * n2;

Label1.Text = Convert.ToString(total); }

3、测试结果

六、查询页面 1、前台关键代码

DataTextField=\ DataValueField=\ OnSelectedIndexChanged=\

BorderColor=\ BorderStyle=\ BorderWidth=\ CellPadding=\ ForeColor=\ GridLines=\


2.后台关键代码

protected void Page_Load(object sender, EventArgs e) { }

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {

String value = DropDownList1.SelectedItem.Text; //Console.WriteLine(value); Label1.Text = value;

OleDbConnection conn = new OleDbConnection(\Source=\ + Server.MapPath(\)); //建立Command对象

OleDbCommand cmd = new OleDbCommand(\ + value + \, conn);

//建立DataAdapter对象

OleDbDataAdapter adp = new OleDbDataAdapter(cmd);

//AccessDataSource2.SelectCommand=\ //GridView1.DataSource = //建立DataSet对象

DataSet ds = new DataSet(); //填充DataSet对象 adp.Fill(ds, \); //绑定数据对象

GridView1.DataSource = ds.Tables[\].DefaultView; GridView1.DataBind(); }

protected void Button1_Click(object sender, EventArgs e) {

String value = DropDownList1.SelectedItem.Text;

OleDbConnection conn = new OleDbConnection(\Source=\ + Server.MapPath(\)); //建立Command对象

OleDbCommand cmd = new OleDbCommand(\ + value + \, conn);

//建立DataAdapter对象

OleDbDataAdapter adp = new OleDbDataAdapter(cmd);

//AccessDataSource2.SelectCommand=\ //GridView1.DataSource = //建立DataSet对象

DataSet ds = new DataSet(); //填充DataSet对象 adp.Fill(ds, \); //绑定数据对象

GridView2.DataSource = ds.Tables[\].DefaultView; GridView2.DataBind();

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4