Usercontrol/SearchList.ascx.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Usercontrol_SearchBooks : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {


        if (!IsPostBack)
        {

            ViewState["PageIndex"] = 0;
            DataBind();
        }

    }
    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "ImageButton" || e.CommandName == "LinkButton")
        {

            string id = ((Label)e.Item.FindControl("Label6")).Text;
            Response.Redirect("~/UI/CommentPage.aspx?id=" + id);
        }
        string  GoodsId = ((Label)e.Item.FindControl("Label6")).Text;//获取当前的DataLIst中所需属性的值

        ShoppingCar cookieCart = new ShoppingCar();
        ShoppingItem shopitem = new ShoppingItem();
        DataBaseShoppingCar datacar = new DataBaseShoppingCar();
        shopitem.Id = Int64.Parse( GoodsId);
        shopitem.Name = ((LinkButton)e.Item.FindControl("LinkButton1")).Text;
        shopitem.Price = double.Parse(((Label)e.Item.FindControl("Label2")).Text);

        shopitem.Quantity = 1;
        if (Session["Name"] == null)
            cookieCart.add(shopitem);
        else
            datacar.add(shopitem.Id.ToString(), Session["UserId"].ToString(), shopitem.Quantity.ToString());
        ((Label)e.Item.FindControl("Label8")).Visible = true;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        switch (((Button)sender).CommandName)
        {
            case "One":
                ViewState["PageIndex"] = 0;
                break;
            case "Two":
                if ((int)ViewState["PageIndex"] > 0)
                    ViewState["PageIndex"] = (int)ViewState["PageIndex"] - 1;
                break;
            case "Three":
                if ((int)ViewState["PageIndex"] < (int)ViewState["PageCount"] - 1)
                    ViewState["PageIndex"] = (int)ViewState["PageIndex"] + 1;
后面还有 43 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。