看看这一个
============
<asp:DataList ID="hh" RepeatColumns="4" runat="server">
<ItemTemplate>
<table width="25%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="30%" height="112" align="center" valign="middle">
<a href="ProductInfo.aspx?Pid=<%# DataBinder.Eval(Container.DataItem, "proid") %>" class="y4" target="_blank">
<img border="0" alt="<%# DataBinder.Eval(Container.DataItem, "pronames") %>" src="<%# DataBinder.Eval(Container.DataItem, "p1") %>" height="79" /></a></td>
<td width="70%" align="right" valign="bottom"><table width="101%" height="100" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td height="20" colspan="2" align="left" class="y4"><p><a href="ProductInfo.aspx?Pid=<%# DataBinder.Eval(Container.DataItem, "proid") %>" class="y4" target="_blank"><%# DataBinder.Eval(Container.DataItem, "pronames") %> <%# DataBinder.Eval(Container.DataItem, "proname") %></a></p></td>
</tr>
<tr>
<td width="48%" height="20" align="left">市场价:</td>
<td width="52%" height="20" align="left" class="zi4"><s><%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "proprice")) %></s>元</td>
</tr>
<tr>
<td height="20" align="left"><span class="zi3">超特价</span>:</td>
<td height="20" align="left"><%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "superprice")) %>元</td>
</tr>
<tr>
<td height="20" colspan="2" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25%" height="20" align="left"><img src="images/index32.jpg" width="24" height="17" /></td>
<td width="75%" height="20" align="center"><img src="images/index33.jpg" width="73" height="20" border="0" class="buttoncss" onClick="x3('<%# DataBinder.Eval(Container.DataItem, "proid") %>')" /></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList></td>
</tr>
<tr><td><asp:Label ID="pages" runat="server"></asp:Label> 共<asp:Label ID="PageCount" runat="server"></asp:Label>页,当前第<asp:Label ID="CurrentPage" runat="server"></asp:Label>页,
<asp:LinkButton ID="FirstPage" runat="server" Text="首页" OnClick="FirstPage_Click"></asp:LinkButton> <asp:LinkButton ID="LastPage" runat="server" Text="上一页" OnClick="LastPage_Click"></asp:LinkButton>
<asp:LinkButton ID="NextPage" runat="server" Text="下一页" OnClick="NextPage_Click"></asp:LinkButton>
<asp:LinkButton ID="EndPage" runat="server" Text="末页" OnClick="EndPage_Click"></asp:LinkButton> 转到<asp:TextBox ID="ReturnPage" runat="server" Width="25" Height="22"></asp:TextBox><asp:Button ID="Go" runat="server" Text="GO" Height="22" OnClick="TurnToPage_Click" />
=================================
============
<asp:DataList ID="hh" RepeatColumns="4" runat="server">
<ItemTemplate>
<table width="25%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="30%" height="112" align="center" valign="middle">
<a href="ProductInfo.aspx?Pid=<%# DataBinder.Eval(Container.DataItem, "proid") %>" class="y4" target="_blank">
<img border="0" alt="<%# DataBinder.Eval(Container.DataItem, "pronames") %>" src="<%# DataBinder.Eval(Container.DataItem, "p1") %>" height="79" /></a></td>
<td width="70%" align="right" valign="bottom"><table width="101%" height="100" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td height="20" colspan="2" align="left" class="y4"><p><a href="ProductInfo.aspx?Pid=<%# DataBinder.Eval(Container.DataItem, "proid") %>" class="y4" target="_blank"><%# DataBinder.Eval(Container.DataItem, "pronames") %> <%# DataBinder.Eval(Container.DataItem, "proname") %></a></p></td>
</tr>
<tr>
<td width="48%" height="20" align="left">市场价:</td>
<td width="52%" height="20" align="left" class="zi4"><s><%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "proprice")) %></s>元</td>
</tr>
<tr>
<td height="20" align="left"><span class="zi3">超特价</span>:</td>
<td height="20" align="left"><%# Convert.ToInt32(DataBinder.Eval(Container.DataItem, "superprice")) %>元</td>
</tr>
<tr>
<td height="20" colspan="2" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25%" height="20" align="left"><img src="images/index32.jpg" width="24" height="17" /></td>
<td width="75%" height="20" align="center"><img src="images/index33.jpg" width="73" height="20" border="0" class="buttoncss" onClick="x3('<%# DataBinder.Eval(Container.DataItem, "proid") %>')" /></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList></td>
</tr>
<tr><td><asp:Label ID="pages" runat="server"></asp:Label> 共<asp:Label ID="PageCount" runat="server"></asp:Label>页,当前第<asp:Label ID="CurrentPage" runat="server"></asp:Label>页,
<asp:LinkButton ID="FirstPage" runat="server" Text="首页" OnClick="FirstPage_Click"></asp:LinkButton> <asp:LinkButton ID="LastPage" runat="server" Text="上一页" OnClick="LastPage_Click"></asp:LinkButton>
<asp:LinkButton ID="NextPage" runat="server" Text="下一页" OnClick="NextPage_Click"></asp:LinkButton>
<asp:LinkButton ID="EndPage" runat="server" Text="末页" OnClick="EndPage_Click"></asp:LinkButton> 转到<asp:TextBox ID="ReturnPage" runat="server" Width="25" Height="22"></asp:TextBox><asp:Button ID="Go" runat="server" Text="GO" Height="22" OnClick="TurnToPage_Click" />
=================================
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 PMenu : System.Web.UI.Page
{
private static string SQLString = String.Empty;
private PagedDataSource pg = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GetMoData();
}
} #region 绑定数据
protected void GetMoData()
{
//判断是何栏目
if (Request.QueryString["kid"] != null)
{
int kid = Convert.ToInt32(Request.QueryString["kid"].ToString());
switch (kid)
{
case 1:
SQLString = "Select b.proid, b.proname, b.proprice, b.superprice, a.proname As pronames, b.p1 From programs As a Inner Join products As b On a.proid = b.prokid";
moinfo.Text = "手机产品";
break; case 2:
SQLString = "Select b.proid, b.proname, b.proprice, b.superprice, a.proname As pronames, b.p1 From programs As a Inner Join products As b On a.proid = b.prokid Where b.prokind Like '%3G%'";
moinfo.Text = "3G专区";
break; case 3:
SQLString = "select a.p1,a.proname,a.proid,a.proprice,a.superprice,a.p1,b.proname as pronames FROM products a join programs b on(a.prokid=b.proid) order by a.proid desc";
moinfo.Text = "新机上市";
break; case 4:
SQLString = "select a.p1,a.proname,a.proid,a.proprice,a.superprice,a.p1,b.proname as pronames FROM products a join programs b on(a.prokid=b.proid) where a.pronice=1 order by a.proid desc";
moinfo.Text = "畅销机型";
break; default:
SQLString = "Select b.proid, b.proname, b.proprice, b.superprice,a.proname As pronames, b.p1 From programs As a Inner Join products As b On a.proid = b.prokid";
moinfo.Text = "手机产品";
break;
}
}
SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString);
SqlDataAdapter ad = new SqlDataAdapter(SQLString, cnn);
DataSet ds = new DataSet();
ad.Fill(ds);
pg=new PagedDataSource();
pg.PageSize = 32;
pg.AllowPaging = true;
if (CurrrentPage2.Value != "")
{
pg.CurrentPageIndex = int.Parse(CurrrentPage2.Value);
}
pg.DataSource = ds.Tables[0].DefaultView;
hh.DataSource = pg;
hh.DataBind();
PageCount.Text = pg.PageCount.ToString();
CurrentPage.Text = (pg.CurrentPageIndex + 1).ToString();
if (pg.CurrentPageIndex == 0)
{
FirstPage.Enabled = false;
}
else
{
FirstPage.Enabled = true;
}
if (pg.CurrentPageIndex == 0)
{
LastPage.Enabled = false;
}
else
{
LastPage.Enabled = true;
}
if (pg.CurrentPageIndex == pg.PageCount - 1)
{
NextPage.Enabled = false;
}
else
{
NextPage.Enabled = true;
}
if (pg.CurrentPageIndex == pg.PageCount - 1)
{
EndPage.Enabled = false;
}
else
{
EndPage.Enabled = true;
}
CurrrentPage2.Value = pg.CurrentPageIndex.ToString();
}
#endregion #region 分页
/// <summary>
/// 首页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void FirstPage_Click(object sender, EventArgs e)
{
CurrrentPage2.Value = "0";
GetMoData();
}
/// <summary>
/// 上一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void LastPage_Click(object sender, EventArgs e)
{
int Page1 = int.Parse(CurrrentPage2.Value);
if (Page1 > 0)
{
CurrrentPage2.Value = (Page1 - 1).ToString();
GetMoData();
}
}
/// <summary>
/// 下一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void NextPage_Click(object sender, EventArgs e)
{
int Page1 = int.Parse(CurrrentPage2.Value);
if (Page1 < int.Parse(PageCount.Text))
{
CurrrentPage2.Value = (Page1 + 1).ToString();
GetMoData();
}
}
/// <summary>
/// 末页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void EndPage_Click(object sender, EventArgs e)
{
CurrrentPage2.Value = (int.Parse(PageCount.Text) - 1).ToString();
GetMoData();
}
/// <summary>
/// 转到第几页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TurnToPage_Click(object sender, EventArgs e)
{
//判断是否正整数
if (System.Text.RegularExpressions.Regex.IsMatch(ReturnPage.Text, @"^[1-9][0-9]*$"))
{
//判断输入的页码是否大于最大页
if (int.Parse(ReturnPage.Text) > int.Parse(PageCount.Text))
{
Response.Write("<script language='javascript'>alert('输入的页码过大!')</script>");
}
else
{
CurrrentPage2.Value = (int.Parse(ReturnPage.Text) - 1).ToString();
GetMoData();
}
}
else
{
Response.Write("<script language='javascript'>alert('请输入大于0的数字!')</script>");
}
}
#endregion}
http://www.188ggg.com/PMenu.aspx?kid=1