请问!怎么样获取datalist里面的控件? C# ASP.NET 我在datalist的底部加了分页的四个button:首页,上一页,下一页,尾页在做后台代码时,我想要一个效果,就是当在第一页的时候,首页和上一页的enable=false;在最后一页的时候,下一页和尾页的enable=false;想请教大家,该怎么做呢?无论是javascript代码也好,还是后台代码也好,因为是新手,所以想请大家说详细点,谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 gridview 里面好做点儿吧、、、这个表示没在datalist里面弄过。试一试:CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("ckbox"); 对应着改改哈,比如 checkbox 改成 button 试一试然后加判断 if(){...} private void SetLinkButton() { btnFirst.Enabled = true; btnPrev.Enabled = true; btnNext.Enabled = true; btnLast.Enabled = true; if (txtPageIndex.Text == "1") { btnFirst.Enabled = false; btnPrev.Enabled = false; } Maticsoft.BLL.Products pBll = new Maticsoft.BLL.Products(); if (txtPageIndex.Text == pBll.GetPagedListCount(int.Parse(txtPageSize.Text), string.Empty).ToString()) { btnNext.Enabled = false; btnLast.Enabled = false; } } 用个AspNetPager控件不很简单吗,http://www.webdiyer.com/Controls/AspNetPager 给你一段代码自己模仿改一下。public void dataBindhypertensionhome() { PagedDataSource pds = new PagedDataSource(); pds.DataSource = B_hypertension.getHypertensionhome(); pds.AllowPaging = true; pds.PageSize = 1; int currentIndex = Convert.ToInt32(this.lbl_currentpage.Text) - 1; pds.CurrentPageIndex = currentIndex; if (currentIndex == 0) { this.lbt_previouspage.Enabled = false; } else { this.lbt_previouspage.Enabled = true; } if (currentIndex == pds.PageCount - 1) { this.lbt_nextpage.Enabled = false; } else { this.lbt_nextpage.Enabled = true; } this.lbl_totalpage.Text = pds.PageCount.ToString(); this.DataList1.DataSource = pds; this.DataList1.DataBind(); } 怎么理解持久层? 为什么URl重写, 二级域名总是跳转到首页? ASP.net 关于SQL2000数据库存取二进制文件 求助:FCKeditor 背景色怎么修改? 当用户在textbox里面输入某些特定字符串的时候,如何识别呢? 如何实现com组件不需要注册?请指教! .net管理服务器 [高分求解] 请问高手,如何在程序运行中动态地加入控件,控件的位置怎么控制? 不能增加Datagrid的模板列了,怪了 NHibernate的Session为什么是线程不安全的? 获取gridview某单元格的数据绑定字段 近来用ASP.NET做了个站,放到服务器上,运行一会就打不开aspx页面了
试一试:CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("ckbox"); 对应着改改哈,比如 checkbox 改成 button 试一试
然后加判断 if(){...}
{
btnFirst.Enabled = true;
btnPrev.Enabled = true;
btnNext.Enabled = true;
btnLast.Enabled = true; if (txtPageIndex.Text == "1")
{
btnFirst.Enabled = false;
btnPrev.Enabled = false;
}
Maticsoft.BLL.Products pBll = new Maticsoft.BLL.Products();
if (txtPageIndex.Text == pBll.GetPagedListCount(int.Parse(txtPageSize.Text), string.Empty).ToString())
{
btnNext.Enabled = false;
btnLast.Enabled = false;
}
}
public void dataBindhypertensionhome()
{
PagedDataSource pds = new PagedDataSource();
pds.DataSource = B_hypertension.getHypertensionhome(); pds.AllowPaging = true;
pds.PageSize = 1;
int currentIndex = Convert.ToInt32(this.lbl_currentpage.Text) - 1; pds.CurrentPageIndex = currentIndex;
if (currentIndex == 0)
{ this.lbt_previouspage.Enabled = false; }
else
{
this.lbt_previouspage.Enabled = true; }
if (currentIndex == pds.PageCount - 1)
{ this.lbt_nextpage.Enabled = false; }
else
{
this.lbt_nextpage.Enabled = true;
}
this.lbl_totalpage.Text = pds.PageCount.ToString(); this.DataList1.DataSource = pds;
this.DataList1.DataBind();
}