protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ViewState["textname"] = ""; ViewState["sum"] = 0; } if (Convert.ToInt32(ViewState["sum"].ToString()) > 1) { SeachData(Convert.ToInt32(ViewState["sum"].ToString())); } } private void SeachData(int sum) { this.PlaceHolder1.Controls.Clear(); double index = sum / 10; if (index > 10) { for (int i = 1; i <= 10; i++) { LinkButton lb = new LinkButton(); lb.Text = String.Format("{0}", i); lb.Click += new EventHandler(lb_Click); this.PlaceHolder1.Controls.Add(lb); } } else { for (int i =1; i <= index; i++) { LinkButton lb = new LinkButton(); lb.Text = String.Format("{0}",i); lb.Click+=new EventHandler(lb_Click); this.PlaceHolder1.Controls.Add(lb); } } } #region 点击事件 void lb_Click(object sender, EventArgs e) { LinkButton lb = (LinkButton)sender; string str = lb.Text; int index = Convert.ToInt32(lb.Text);//获取当前点击的页数 } #endregion
1 回答
婷婷同学_
TA贡献1844条经验 获得超8个赞
if (Convert.ToInt32(ViewState["sum"].ToString()) > 1)
{
SeachData(Convert.ToInt32(ViewState["sum"].ToString()));
}
这里事件被重新绑定了
- 1 回答
- 0 关注
- 639 浏览
添加回答
举报
0/150
提交
取消