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

📄 productitem.aspx.cs

📁 电子商务网站转载而来[展开所有目录] [建议增加分类] (重要) 您上载的源码为何会被站长不采用或帐号被删除? 1.源码太简单 2.不是源码 3.缺少文件 4.所选类别和开发环境
💻 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;
using System.Text;
using Model;
using BLL;

public partial class ProductItem : System.Web.UI.Page
{
    protected string txtTitle = string.Empty;
    public string txtCategory = string.Empty;
    public string txtCurrentPage = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ReTitle();
            Item bll = new Item();
            CategoryName.Text = bll.GetCategoryNameByProductId(GetProductId());
            LinkBind();
            PsPageData();
            PageData();

        }
    }
    protected void ReTitle() {

        txtCategory = Request.QueryString["Product"];
        switch (txtCategory) {
        
            case "Coat":
                txtTitle = "外 套  开心商城网";
                break;
            case "Computer":
                txtTitle = "电 脑  开心商城网";
                break;
            case "HuFu":
                txtTitle = "护 肤  开心商城网";
                break;
            case "MianMo":
                txtTitle = "面 膜  开心商城网";
                break;
            case "MP3":
                txtTitle = "MP3  开心商城网";
                break;
            case "PeiShi":
                txtTitle = "配 饰  开心商城网";
                break;
            case "Shirt":
                txtTitle = "衬 衫  开心商城网";
                break;
            case "ShouJi":
                txtTitle = "手 机  开心商城网";
                break;
            case "Skirt":
                txtTitle = "裙 子  开心商城网";
                break;
            case "Soprts":
                txtTitle = "运动鞋  开心商城网";
                break;
            case "TouShi":
                txtTitle = "头 饰  开心商城网";
                break;
            default:
                txtTitle = "拖鞋  开心商城网";
                break;
        
        }

    
    }
    //获得类别的名称
    public string GetProductId()
    {

        txtCategory = Request.QueryString["Product"];
        if (txtCategory == null)
        {

            return "Coat";

        }
        else
        {

            return txtCategory;

        }

    }
    //分页
    protected PagedDataSource PsPageData()
    {

        Item bll = new Item();
        PagedDataSource ps = new PagedDataSource();
        ps.DataSource = bll.GetItemByProduct(GetProductId());
        ps.AllowPaging = true;
        ps.PageSize = 24;
        string txtPa = Request.QueryString["page"];
        string txtCurrent = string.Empty;
        if (txtPa != null)
        {
            ps.CurrentPageIndex = Convert.ToInt32(txtPa) - 1;
        }
        else
        {

            ps.CurrentPageIndex = 0;

        }

        RepeaterCategory.DataSource = ps;
        RepeaterCategory.DataBind();
        return ps;

    }
    //分页链接判断
    public void LinkBind()
    {

        string txtPage = string.Empty;
        LinkIndex.Enabled = true;
        LinkUp.Enabled = true;
        LinkDown.Enabled = true;
        LinkEnd.Enabled = true;
        txtPage = Request.QueryString["page"];
        if (txtPage != null)
        {

            txtCurrentPage = txtPage;

        }
        else
        {

            txtCurrentPage = "1";

        }
        if (PsPageData().IsFirstPage)
        {

            LinkIndex.Enabled = false;
            LinkUp.Enabled = false;

        }
        else
        {

            int txtPa = Convert.ToInt32(txtCurrentPage) - 1;
            LinkIndex.NavigateUrl = "?page=1";
            LinkUp.NavigateUrl = "?page=" + txtPa + "";

        }
        if (PsPageData().IsLastPage)
        {

            LinkDown.Enabled = false;
            LinkEnd.Enabled = false;

        }
        else
        {

            int txtPa = Convert.ToInt32(txtCurrentPage) + 1;
            LinkDown.NavigateUrl = "?page=" + txtPa + "";
            LinkEnd.NavigateUrl = "?page=" + PsPageData().PageCount + "";

        }


    }
    //分页链接的判断
    protected void PageData()
    {

        StringBuilder builder = new StringBuilder();
        int txtPageCount = PsPageData().PageCount;
        string txtCur = Request.QueryString["page"];
        for (int i = 1; i <= txtPageCount; i++)
        {

            if (txtCur != null)
            {

                if (txtCur == i.ToString())
                {

                    builder.Append("[" + i + "]");

                }
                else
                {

                    builder.Append("<a href=\"?page=" + i + "\">[" + i + "]</a>");

                }

            }

            else
            {

                if (i == 1)
                {
                    builder.Append("[" + i + "]");
                }
                else
                {

                    builder.Append("<a href=\"?page=" + i + "\">[" + i + "]</a>");

                }

            }

        }

        FootTwoNum.InnerHtml = builder.ToString();

    }
    public string SubName(string nName)
    {

        string txtName = string.Empty;
        if (nName.Length < 8)
        {

            return nName;

        }
        else
        {

            txtName = nName.Substring(0, 8);
            return txtName;

        }

    }
}

⌨️ 快捷键说明

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