1 Star 1 Fork 0

嘎嘎/基于ASP.NET的web开发

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
products.aspx.cs 5.42 KB
一键复制 编辑 原始数据 按行查看 历史
嘎嘎 提交于 2021-07-07 10:15 . 基于Asp.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
public partial class products : System.Web.UI.Page
{
public static string quming = "装饰摆饰";
public static string query = "";
public static string[] state=new string[6];
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["item"] != null)
{
quming = Request.QueryString["item"].ToString();
switch(quming)
{
case "装饰摆饰":
state[0] = "active";
state[1] = "grid";
state[2] = "grid";
state[3] = "grid";
state[4] = "grid";
state[5] = "grid";
break;
case "厨房餐饮":
state[0] = "grid";
state[1] = "active";
state[2] = "grid";
state[3] = "grid";
state[4] = "grid";
state[5] = "grid";
break;
case "办公文具":
state[0] = "grid";
state[1] = "grid";
state[2] = "active";
state[3] = "grid";
state[4] = "grid";
state[5] = "grid";
break;
case "玩具娱乐":
state[0] = "grid";
state[1] = "grid";
state[2] = "grid";
state[3] = "active";
state[4] = "grid";
state[5] = "grid";
break;
case "智能科技":
state[0] = "grid";
state[1] = "grid";
state[2] = "grid";
state[3] = "grid";
state[4] = "active";
state[5] = "grid";
break;
case "全部":
state[0] = "grid";
state[1] = "grid";
state[2] = "grid";
state[3] = "grid";
state[4] = "grid";
state[5] = "active";
break;
default:
state[0] = "grid";
state[1] = "grid";
state[2] = "grid";
state[3] = "active";
break;
}
string strsql;
if (!quming.Equals("全部"))
strsql = "select * from Db_Prodouct where pType = '" + quming + "' order by ID desc";
else
strsql = "select * from Db_Prodouct order by ID desc";
DataTable dt = new DataTable();
dt = OleDbHelper.GetDataTable(strsql);
GetRptBind(dt);
}
else if (Request.QueryString["query"] != null)
{
query = Request.QueryString["query"].ToString();
quming = "全部";
state[0] = "grid";
state[1] = "grid";
state[2] = "grid";
state[3] = "active";
string strquery = "select * from Db_Prodouct where pTitle like '%'+@title+'%' order by ID desc";
OleDbParameter para = new OleDbParameter("@title", query);
DataTable dt = new DataTable();
dt = OleDbHelper.GetDataTable(strquery,para);
GetRptBind(dt);
}
else
{
Response.Redirect("index.aspx");
return;
}
}
}
private void GetRptBind(DataTable dt)
{
PagedDataSource pds = new PagedDataSource();
pds.PageSize = AspNetPager1.PageSize;
pds.AllowPaging = true;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
AspNetPager1.RecordCount = dt.Rows.Count;
int pagecount = AspNetPager1.PageCount;
DataView dv = dt.DefaultView;
pds.DataSource = dv;
rpt.DataSource = pds;
rpt.DataBind();
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
string strsql;
DataTable dt = new DataTable();
if (!quming.Equals("全部"))
{
strsql = "select * from Db_Prodouct where pType = '" + quming + "' order by ID desc";
dt = OleDbHelper.GetDataTable(strsql);
}
else if (query == "")
{
strsql = "select * from Db_Prodouct order by ID desc";
dt = OleDbHelper.GetDataTable(strsql);
}
else
{
strsql = "select * from Db_Prodouct where pTitle like '*@query*' order by ID desc";
OleDbParameter para = new OleDbParameter("@title", query);
dt = OleDbHelper.GetDataTable(strsql, para);
}
GetRptBind(dt);
}
protected void btnQuery_Click(object sender, EventArgs e)
{
Response.Redirect("products.aspx?query=" + txtQuery.Text);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/Ophlia_d/aspnet.git
git@gitee.com:Ophlia_d/aspnet.git
Ophlia_d
aspnet
基于ASP.NET的web开发
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385