cargo_list1.aspx.cs

来自「网站开发与实例,提供完整的电子商务网站源代码。」· CS 代码 · 共 86 行

CS
86
字号
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;
using System.Data.SqlClient;

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

    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection strcon = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
        strcon.Open();
        SqlDataAdapter sda = new SqlDataAdapter("select * from tb_Cargo order by id desc",strcon);
        DataSet ds = new DataSet();
        sda.Fill(ds, "tb_Cargo");
        this.GridView1.DataSource = ds.Tables["tb_Cargo"];
        this.GridView1.DataKeyNames = new string[] { "id" };
        this.GridView1.DataBind();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }
    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        string id = this.GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
        Response.Write(id);
        if (Session["bus"] == null)
        {
            System.Collections.Hashtable ht = new Hashtable();

            ht.Add(id, 1);
            Session["bus"] = ht;
            //				Session.Add("bus",ht);
        }

        else
        {
            System.Collections.Hashtable ht = (Hashtable)Session["bus"];
            if (ht[id] == null)
            {
                ht[id] = 1;
            }
            else
            {
                ht[id] = (int)ht[id] + 1;
            }
            Session["bus"] = ht;
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write(Request["Checkbox1"]);
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
    }
    protected void Button1_Click1(object sender, EventArgs e)
    {
        this.DataList1.DataSource =(Hashtable)Session["bus"];
        this.DataList1.DataBind();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
       
    }
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {

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


    }
}

⌨️ 快捷键说明

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