[已解决问题]
解决于 2008-08-08 12:57
protected void Page_Load(object sender, EventArgs e)<BR> {<BR> if (!Page.IsPostBack)<BR> {<BR> ViewState["textname"] = "";<BR> ViewState["sum"] = 0;<BR> }<BR> if (Convert.ToInt32(ViewState["sum"].ToString()) > 1)<BR> {<BR> SeachData(Convert.ToInt32(ViewState["sum"].ToString()));<BR> }<BR> }<BR> <BR> private void SeachData(int sum)<BR> {<BR> this.PlaceHolder1.Controls.Clear();<BR> double index = sum / 10;<BR> if (index > 10)<BR> {<BR> for (int i = 1; i <= 10; i++)<BR> {<BR> LinkButton lb = new LinkButton();<BR> lb.Text = String.Format("{0}", i);<BR> lb.Click += new EventHandler(lb_Click);<BR> this.PlaceHolder1.Controls.Add(lb);<BR> }<BR> }<BR> else<BR> {<BR> for (int i =1; i <= index; i++)<BR> {<BR> LinkButton lb = new LinkButton();<BR> lb.Text = String.Format("{0}",i);<BR> lb.Click+=new EventHandler(lb_Click);<BR> this.PlaceHolder1.Controls.Add(lb);<BR> }<BR> }<BR> }<BR> <BR> #region 点击事件<BR> void lb_Click(object sender, EventArgs e)<BR> {<BR> LinkButton lb = (LinkButton)sender;<BR> string str = lb.Text;<BR> int index = Convert.ToInt32(lb.Text);//获取当前点击的页数<BR> }<BR> #endregion
思惟
|
初学一级
|
园豆:
200
提问于:2008-08-04 15:50