同一个页面内根据分类查询
来源:互联网 发布:网络诈骗手段有哪些 编辑:程序博客网 时间:2024/05/21 17:58
Proj.aspx:
<asp:ListView ID="ListView1" runat="server"
GroupItemCount="6" style="text-align: center"
>
<LayoutTemplate >
<table id="Table1" runat ="server" style ="width :98%; height :auto ">
<tr runat ="server" id="groupPlaceholder" style ="width :50%; height :auto "></tr>
</table>
</LayoutTemplate>
<GroupTemplate >
<tr id="Tr1" runat ="server">
<td runat ="server" id="itemPlaceholder"></td>
</tr>
</GroupTemplate>
<ItemTemplate >
<td id="Td1" runat ="server" >
<table style="border: 1px ; height: 113px; width: 100%; text-align: center;">
<tr>
<td colspan="2" style="width: 174px; vertical-align :middle ;text-align: center; ">
<img alt="截图" height="110" src="image/pic/<%#Eval("图片") %>" width="100" style="padding: 2px" /></td>
</tr>
<tr>
<td colspan="2"> <%# Intercept(Eval("名称").ToString ())%></td></tr>
<td><a href ="<%#Eval("主页地址")%>" style="border: 2px solid #FF00FF; background-color: #CCCCCC;">转到>></a></td>
<td><a href ="Proj_body.aspx?id=<%#Eval("货号")%>" style="border: 2px solid #FF00FF; background-color: #CCCCCC;">详情>></a></td>
</tr>
</table>
</td>
</ItemTemplate>
</asp:ListView>
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1"
PageSize="30">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowNextPageButton="False" />
<asp:NumericPagerField ButtonType="Button" />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
Class1.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data .OleDb ;
using System.Data ;
namespace Mane
{
public class Class1
{
public OleDbConnection strcon(string path)
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+path );
return con;
}
public DataTable selectTable(string sqltext, OleDbConnection con)
{
DataTable dt = new DataTable();
OleDbDataAdapter adp = new OleDbDataAdapter(sqltext, con);
adp.Fill(dt);
return dt;
}
public void selectcmd(string sqltext, OleDbConnection con)
{
OleDbCommand cmd = con.CreateCommand();
cmd.CommandText = sqltext;
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception e)
{
throw new SystemException(e.Message);
}
finally
{
con.Close();
}
}
}
}
Proj.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Mane;
using System.Data.OleDb;
using System.Data;
namespace Luck28
{
public partial class WebForm4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string qstr = Request.QueryString["id"];
if (qstr != null && qstr != "")
{
//如果点击了分类链接并传递了字符串则查询
Class1 cs = new Class1();
OleDbConnection con = cs.strcon(@Server.MapPath("/App_Data/Proj.mdb"));
string sql = "SELECT * FROM Proj WHERE 所属分类='" + qstr + "' ORDER BY 排名竞价 DESC";
DataTable dt = cs.selectTable(sql, con);
ListView1.DataSource = dt;
ListView1.DataBind();
}
else
{
//如果未点击链接直接进入该网页
Class1 cs = new Class1();
OleDbConnection con = cs.strcon(@Server.MapPath("/App_Data/Proj.mdb"));
string sql = "SELECT * FROM Proj ORDER BY 排名竞价 DESC";
DataTable dt = cs.selectTable(sql, con);
ListView1.DataSource = dt;
ListView1.DataBind();
}
}
//将长度大于4的字符串截短
protected string Intercept(string sInput)
{
if (sInput != null && sInput != string.Empty)
{
if (sInput.Length > 4)
return sInput = sInput.Substring(0, 4) + "...";
else
return sInput;
}
return "";
}
}
}
- 同一个页面内根据分类查询
- 同一个表单 根据要求递交到不同页面 总结
- 同一个页面内实现html+js表单提交输出功能
- 【JQuery:多个页面在同一个div内显示】
- 局域网内根据Ip查询主机名
- jsp页面中同一个超链接地址根据不同的条件而跳到不同的页面
- 同一个表单 根据要求递交到不同页面的实现方法小结
- 根据表中某个字段的首字母进行分类查询
- PHP根据大分类查询所有子类文章包括自身
- 查询出来的结果根据某一字段进行分类
- mysql根据时间戳查询指定日期内数据
- mongodb中根据内嵌文档中的条件查询
- oracle中在同一个表中分类查询不同类型的前几条数据
- 如何在同一个页面内使用不同的超级链接,如何定义这类CSS。
- 同一个页面内Ajax过多导致SendRedirect抛java.lang.IllegalStateException异常
- 乐商商品分类 可按照SQL 同一个表、单表 联合查询 导出商品分类数据
- Mysql同一个事务内记录成功插入后查询不出来
- 同一个页面变量传递
- MyEclipse插件全接触
- [.net framework4.0]基于.NET Framework 4.0的解决方案部署
- spool方式取数据
- 多线程
- FOJ 1914. Funny Positive Sequence 【单调队列优化】
- 同一个页面内根据分类查询
- SQL Server游标实例演示不得不看
- ASP/SQL 注入天书
- TOJ 2217. Invitation Cards【最短路dijkstra+堆优化或者SPFA】
- sgu 101. Domino
- ADO.NET站内模糊搜索
- 网络编程(八)非阻塞套接字的连接和select
- MyQQ 第一阶段完成
- 改mdb为asp所带来的灾难