部分代码如:
AllowPaging="True"
AllowCustomPaging="True"
BorderStyle="Solid"
DataKeyField="KeyID"
AutoGenerateColumns="false"
PageSize="2"
CellPadding="0"
CellSpacing="0"
AllowSorting="False"
AlternatingItemStyle-BackColor="#eeeeee"
HeaderStyle-CssClass="title"
Width="100%"
OnPageIndexChanged="objDG_OnPageChange"
且已经设置了VirtualItemCount的值且值也正确,但在输出显示DataGrid的PageCount时就是1,PageSize的值也正确,不使用自定义分页可以正常分页,但使用自定义分页却不可以。
已经添加了OnPageIndexChanged事件,且已绑定了数据源,
AllowPaging="True"
AllowCustomPaging="True"
BorderStyle="Solid"
DataKeyField="KeyID"
AutoGenerateColumns="false"
PageSize="2"
CellPadding="0"
CellSpacing="0"
AllowSorting="False"
AlternatingItemStyle-BackColor="#eeeeee"
HeaderStyle-CssClass="title"
Width="100%"
OnPageIndexChanged="objDG_OnPageChange"
且已经设置了VirtualItemCount的值且值也正确,但在输出显示DataGrid的PageCount时就是1,PageSize的值也正确,不使用自定义分页可以正常分页,但使用自定义分页却不可以。
已经添加了OnPageIndexChanged事件,且已绑定了数据源,
解决方案 »
- 多条件查询,并非stringbuilder.append 拼接字符串。每次点击都出现查询结果并记录其它值
- gridview的viewstate使rowcommand事件无法被捕捉到
- 菜鸟问题
- 关于listbox
- 不规则excel表数据导入sql里有什么好的方法
- datagrid 动态创健的模版列,模版列中文本控件,后台无法获得更新后的值. 找了好多贴子没有一个能解决的.(高手现身)
- Asp里我要在页面里重复内容,只要<%for i=0 to 8%>内容<%next%>,这样就可以,asp.net里如何实现类似功能,很难啊
- 关于ASP.net结合Flash AS3操作数据库的问题
- 我就想提取正常和不正常到DropDownList1里(怎样读取这个XML)
- 〓〓100分求高人,怎么读取一个字段的内容并显示出子集来,有点像动网,解决立即给分!〓〓
- smartnavigation和textchange event的问题,50分
- 问个问题:我想把我的电脑里的信息通过移动或者联通向手机(任何品牌)客户发送短消息。客户的手机接到电脑上。通过电脑显示短信息。该怎
{
int startIndex ;
startIndex = dg.CurrentPageIndex * dg.PageSize;
dg.CurrentPageIndex = e.NewPageIndex;
this.BindGrid();//自己重新绑定数据
}
private void ListClassDataGrid_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
ListClassDataGrid.CurrentPageIndex = e.NewPageIndex;
BindData();
}
这个也写了.
private void objDG_SelectedIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
objDG.CurrentPageIndex = e.NewPageIndex;
下两行不是必要的
oraDA1.Fill(dataSet**);//此句填充dataset,要根据你的需要改
objDG.DataBind();
}objDG是你的DataGrid名字,
一定行
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
……重新绑定数据……
}
这样做一下!
Page_Load中增加If Not IsPostBack Then
DataGridDataBound()
End If在PageIndexChanged事件中指定
DataGrid1.CurrentPageIndex = e.NewPageIndex ;
DataGridDataBound();
重新进行绑定
在Page_Load方法中加入如下判断:
if (!Page.IsPostBack)
{
BindDataGrid();
}
在PageIndexChanged事件中加入如下代码:
DataGrid1.CurrentPageIndex = e.NewPageIndex;
BindDataGrid();
{
BindDataGrid();
}
对,这句很重要,许多datagrid问都出在没有执地这句上.
Code:
<asp:DataGrid ID="objDG" AllowPaging="True" AllowCustomPaging="True" BorderStyle="Solid" DataKeyField="KeyID" AutoGenerateColumns="false" CellPadding="0" CellSpacing="0" AllowSorting="False" AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-CssClass="title" Width="100%" Runat="server">
<ItemStyle Height="22" />
<PagerStyle HorizontalAlign="Right" PrevPageText="上一页" NextPageText="下一页" Mode="NextPrev" PageButtonCount="5" CssClass="SplitPage" />if(!Page.IsPostBack)
{
this.DataBindSource(1);
this.objDG.VirtualItemCount = RecordCounts;
}protected void objDG_OnPageChange(object s,System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
CurrentPage = e.NewPageIndex+1;
this.objDG.CurrentPageIndex = e.NewPageIndex;
this.DataBindSource(CurrentPage);
}
现在的问题就是数据可以显示,但只能显示第一页的,且没有分页时的链接,但一改变PagerStyle.Mode的值就可以显示了.
-------------------------------------------------------
if(!Page.IsPostBack)
{
this.DataBindSource(1);
this.objDG.VirtualItemCount = RecordCounts;
}
-------------------------------------------------------
将这两句调换一下位置就可以了,因为先绑定数据源,此时的RecordCounts的数据值为0,所以DagaGrid认为其只有一页.