下拉菜单跳转就是不能正确跳转!?

hopefans 2008-07-03 05:19:46
前一页后一页都是正常翻页 ,但是下拉菜单页面跳转,不跳转,选了还是会跳转到当前所在页。不知道咋回事,谢谢各位大虾了




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.Data.SqlClient;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Bind();
}
private void Bind()
{
int cup = Convert.ToInt32(pagelbl.Text);
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["temp"].ConnectionString);
PagedDataSource pds = new PagedDataSource();
SqlDataAdapter sda = new SqlDataAdapter("select * from main", con);
DataSet ds = new DataSet();
sda.Fill(ds,"tabe");
pds.DataSource = ds.Tables["tabe"].DefaultView;
pds.AllowPaging = true;
pds.CurrentPageIndex = 0;
pds.PageSize = 10;
DataList1.DataSource = pds;

pds.CurrentPageIndex = cup - 1;
if (!IsPostBack)
{//判断页面是否第一次载入
for (int i = 1; i <= pds.PageCount; i++)
{//循环出页码
pageddl.Items.Add(i.ToString());
}
}
//下面主要是控制上下翻页按纽是否起用
pageup.Enabled = true;
pagedown.Enabled = true;
if (pds.IsFirstPage)
{//如果是最前页,上页按纽不可用
pageup.Enabled = false;
}
if (pds.IsLastPage)
{//如果是最后页,下页按纽不可用
pagedown.Enabled = false;
}
//设置页码下拉菜单当前选中的值
pageddl.SelectedItem.Text = cup.ToString();
//终于可以绑定给DataList了
DataList1.DataSource = pds;
DataList1.DataKeyField = "id";
DataList1.DataBind();

}


protected void pageddl_SelectedIndexChanged(object sender, EventArgs e)
{//页码下拉菜单事件
pagelbl.Text = pageddl.SelectedItem.Text.ToString();
//pageddl.SelectedValue = pagelbl.Text;
Bind();
}
protected void pagedown_Click(object sender, EventArgs e)
{//下页事件
pagelbl.Text = Convert.ToString(Convert.ToInt32(pagelbl.Text) + 1);
Bind();
}
protected void pageup_Click(object sender, EventArgs e)
{//上页事件
pagelbl.Text = Convert.ToString(Convert.ToInt32(pagelbl.Text) - 1);
pageddl.SelectedValue = pagelbl.Text;
Bind();
}



}
...全文
297 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
CrazyVice 2008-07-03
  • 打赏
  • 举报
回复
if(!Page.IsPostBack)
{
Bind();
}
我姓区不姓区 2008-07-03
  • 打赏
  • 举报
回复
有没有将AutoPostBack设为true
dingfeisoft 2008-07-03
  • 打赏
  • 举报
回复
是不是应该改一下控件的AutoPostBack属性为True
ping3000 2008-07-03
  • 打赏
  • 举报
回复
看看pageddl有没有回发到服务器,AutoPostBack设置为true

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧