效果:
操作效果见www.cz0752.com搜索信息界面
这是小弟第一次涉及服务型网站,由于时间紧,做的很粗糙,希望大家多多支持!
更多精彩待开发中……
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//首页加载
bind();
}
}
private void bind()
{
try
{
this.gwtitle.DataSource ='数据绑定';
gwtitle.AllowPaging = true;
gwtitle.PageSize = 20;
this.gwtitle.DataBind();
}
catch (Exception ex)
{
///抛出异常
throw new Exception();
}
LblCurrentIndex.Text = "当前第<b><font color =red>" + (gwtitle.PageIndex + 1).ToString() + "</font> </b>页";
LblPageCount.Text = "共<font color=red>" + gwtitle.PageCount.ToString() + "</font>页";
if (gwtitle.PageIndex == 0)
{
//如果当前为首页,那么上页和首页按纽不可用
ibt_first.Enabled = false;
ibt_pre.Enabled = false;
}
else
{
ibt_first.Enabled = true;
ibt_pre.Enabled = true;
}
if (gwtitle.PageIndex == gwtitle.PageCount - 1)
{//如果当前为末页,那么下页和末页按纽不可用
ibt_next.Enabled = false;
ibt_last.Enabled = false;
}
else
{
ibt_next.Enabled = true;
ibt_last.Enabled = true;
}
}
protected void ibt_first_Click(object sender, EventArgs e)
{
//首页时当前页索引为0
gwtitle.PageIndex = 0;
this.bind();
}
protected void ibt_pre_Click(object sender, EventArgs e)
{
if (gwtitle.PageIndex > 0)
{
gwtitle.PageIndex--;
}
this.bind();
}
protected void ibt_next_Click(object sender, EventArgs e)
{
if (gwtitle.PageIndex < gwtitle.PageCount - 1)
{
gwtitle.PageIndex++;
}
this.bind();
}
protected void ibt_last_Click(object sender, EventArgs e)
{
gwtitle.PageIndex = gwtitle.PageCount - 1;
this.bind();
}
protected void bnt_go_Click(object sender, EventArgs e)
{
if (tb_pageindex.Text != string.Empty) gwtitle.PageIndex = Convert.ToInt32(tb_pageindex.Text) - 1;
this.bind();
}
//aspx页面
<TBODY>
<TR><TD align=center width=192><asp:Literal id="lb_num" runat="server" __designer:wfdid="w12">
</asp:Literal>
<asp:Label id="LblCurrentIndex" runat="server" Text="Label" __designer:wfdid="w13" CssClass="td_9pt_B"></asp:Label>
<asp:Label id="LblPageCount" runat="server" Text="Label" __designer:wfdid="w14" CssClass="td_9pt_B"></asp:Label></TD>
<TD class="hui912" align=center width=60>
<asp:LinkButton id="ibt_first" onclick="ibt_first_Click" runat="server" Text="首页" __designer:wfdid="w15" CssClass="td_9pt_B"></asp:LinkButton>
</TD><TD style="WIDTH: 42px" align=center width=60>
<asp:LinkButton id="ibt_pre" onclick="ibt_pre_Click" runat="server" Width="60px" Text="上一页" __designer:wfdid="w16" CssClass="td_9pt_B"></asp:LinkButton></TD>
<TD align=center width=60><asp:LinkButton id="ibt_next" onclick="ibt_next_Click" runat="server" Text="下一页" __designer:wfdid="w17" CssClass="td_9pt_B"></asp:LinkButton>
</TD><TD align=center width=60><asp:LinkButton id="ibt_last" onclick="ibt_last_Click" runat="server" Text="末页" __designer:wfdid="w18" CssClass="td_9pt_B"></asp:LinkButton></TD>
<TD class="td_9pt_B" align=center width=35>转到</TD><TD width=35><asp:TextBox id="tb_pageindex" runat="server" Width="30px" __designer:wfdid="w19"></asp:TextBox></TD>
<TD class="td_9pt_B" width=23>页</TD><TD style="WIDTH: 35px">
<asp:Button id="bnt_go" onclick="bnt_go_Click" runat="server" Text="GO" __designer:wfdid="w20" CssClass="td_9pt_B" OnClientClick="return isOpage()"></asp:Button></TD></TR>
</TBODY>
┊☆..培培℡ (363473798) 于 2008-11-23 18:55:53 对此贴进行了编辑



选择表情