`
webcode
  • 浏览: 5938562 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

dataGrid控件的自定义分页(已调试通过)

 
阅读更多


privatevoidDataGNews_ItemCreated(objectsender,System.Web.UI.WebControls.DataGridItemEventArgse)
...{
if(e.Item.ItemType==ListItemType.Pager)
...{

LinkButtonlb
=newLinkButton();
lb.Text
="首页";
e.Item.Controls[
0].Controls.AddAt(0,lb);
LinkButtonend
=newLinkButton();
end.Text
="末页";
e.Item.Controls[
0].Controls.Add(end);
lb.Click
+=newEventHandler(lb_Click);//添加事件处理程序
end.Click+=newEventHandler(end_Click);
HyperLinkzong
=newHyperLink();
zong.Text
=""+this.DataGNews.PageCount+"";
e.Item.Controls[
0].Controls.Add(zong);
HyperLinkper
=newHyperLink();
per.Text
="15条/页 ";
e.Item.Controls[
0].Controls.Add(per);
HyperLinkcur
=newHyperLink();
cur.Text
="当前页是"+(Convert.ToInt32(this.DataGNews.CurrentPageIndex)+1)+"页跳转到";
e.Item.Controls[
0].Controls.Add(cur);
DropDownListddl
=newDropDownList();
ddl.AutoPostBack
=true;//设置DropDownList控件的autopostback属性(自动回发)
for(inti=0;i<this.DataGNews.PageCount;i++)
...{
ddl.Items.Add(
newListItem(""+(i+1)+"",(i+1).ToString()));
}

ddl.SelectedIndexChanged
+=newEventHandler(ddl_SelectedIndexChanged);//添加下拉列表框的"选择改变时"所触发事件SelectedIndexChanged
e.Item.Controls[0].Controls.Add(ddl);
}

}

//事件处理程序
publicvoidlb_Click(objectsender,System.EventArgse)
...{
this.DataGNews.CurrentPageIndex=0;
NewsBind();
}

//事件处理程序

publicvoidend_Click(objectsender,System.EventArgse)
...{
this.DataGNews.CurrentPageIndex=this.DataGNews.PageCount-1;
NewsBind();
}

privatevoidDataGNews_PageIndexChanged(objectsource,System.Web.UI.WebControls.DataGridPageChangedEventArgse)
...{
this.DataGNews.CurrentPageIndex=e.NewPageIndex;
NewsBind();
}

//事件处理程序
publicvoidddl_SelectedIndexChanged(objectsender,EventArgse)
...{
stringval=this.ddl.SelectedValue.ToString();
//Response.Write("<script>alert('"+val+"')</script>");
this.DataGNews.CurrentPageIndex=int.Parse(val)-1;
this.NewsBind();
this.ddl.SelectedValue=(int.Parse(val)).ToString();
}

分享到:
评论

相关推荐

    asp.net专家疑难解答200问源码

    118.如何在DataGrid控件中实现自定义分页功能 119.如何在DataGrid中弹出一个详细信息窗口-示例1 119.如何在DataGrid中弹出一个详细信息窗口-示例2 120. 如何在DataGrid控件中添加CheckBox控件列 121.如何为...

    asp.net专家疑难解答200问

    如何在DataGrid控件中实现自定义分页功能 119.如何在DataGrid中弹出一个详细信息窗口-示例1 119.如何在DataGrid中弹出一个详细信息窗口-示例2 120. 如何在DataGrid控件中添加CheckBox控件列 121....

    DataGrid使用最佳实践(Best Practices for BataGrid)

    DataGrid 中一些常见的用法 包括模板列的使用,导出Excel,分页,自定义控件等等 里面附加有调试用的数据库

    ASP.net技术内幕

    11.3.1 在DataGrid控件中创建列 11.3.2 对DataGrid使用样式 11.3.3 对DataGrid控件中的列进行排序 11.3.4 对DataGrid中的记录进行分页 11.3.5 选择DataGrid控件中的行 11.3.6 编辑...

    asp.net技术内幕(1)

    11.3.2 对DataGrid使用样式 11.3.3 对DataGrid控件中的列进行排序 11.3.4 对DataGrid中的记录进行分页 11.3.5 选择DataGrid控件中的行 11.3.6 编辑DataGrid控件中的条目 11.3.7 使用模板...

    asp.net技术内幕(2)

    11.3.2 对DataGrid使用样式 11.3.3 对DataGrid控件中的列进行排序 11.3.4 对DataGrid中的记录进行分页 11.3.5 选择DataGrid控件中的行 11.3.6 编辑DataGrid控件中的条目 11.3.7 使用模板...

    asp.net技术内幕(5)

    11.3.2 对DataGrid使用样式 11.3.3 对DataGrid控件中的列进行排序 11.3.4 对DataGrid中的记录进行分页 11.3.5 选择DataGrid控件中的行 11.3.6 编辑DataGrid控件中的条目 11.3.7 使用模板...

    asp.net技术内幕(4)

    11.3.2 对DataGrid使用样式 11.3.3 对DataGrid控件中的列进行排序 11.3.4 对DataGrid中的记录进行分页 11.3.5 选择DataGrid控件中的行 11.3.6 编辑DataGrid控件中的条目 11.3.7 使用模板...

    asp.net技术内幕(3)

    11.3.2 对DataGrid使用样式 11.3.3 对DataGrid控件中的列进行排序 11.3.4 对DataGrid中的记录进行分页 11.3.5 选择DataGrid控件中的行 11.3.6 编辑DataGrid控件中的条目 11.3.7 使用模板...

    asp.net知识库

    ASP.NET 2.0:弃用 DataGrid 吧,有新的网格控件了! ASP.NET2.0控件一览---标准控件(1) ASP.NET2.0控件一览---标准控件(2) ASP.NET 2.0中使用webpart系列控件 ASP.NET 2.0 中实现跨页提交 新控件、管理外观、布局及...

Global site tag (gtag.js) - Google Analytics