日期:2014-05-18  浏览次数:20465 次

DataGrid的分页问题
我使用了DataGrid自动分页功能,用在PageIndexChanged事件中写代码吗?如果需要,该如何写?
<asp:datagrid   id= "DataGrid1 "   runat= "server "   Width= "100% "   AutoGenerateColumns= "False "   BorderColor= "#0069B3 "
AllowPaging= "True ">
<Columns>
<asp:BoundColumn   Visible= "False "   DataField= "qy_id "   ReadOnly= "True "   HeaderText= "难易系数编号 "> </asp:BoundColumn>
<asp:TemplateColumn   HeaderText= "难易系数名称 ">
<HeaderStyle   HorizontalAlign= "Center "   ForeColor= "White "   BackColor= "#72AED8 "> </HeaderStyle>
<ItemStyle   HorizontalAlign= "Center "> </ItemStyle>
<ItemTemplate>
<asp:Label   id=Label1   runat= "server "   Text= ' <%#   DataBinder.Eval(Container,   "DataItem.qy_name ")   %> '>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox   id=TextBox2   runat= "server "   Text= ' <%#   DataBinder.Eval(Container,   "DataItem.qy_name ")   %> '>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn   ButtonType= "LinkButton "   UpdateText= "更新 "   HeaderText= "编辑 "   CancelText= "取消 "   EditText= "编辑 ">
<HeaderStyle   HorizontalAlign= "Center "   ForeColor= "White "   BackColor= "#72AED8 "> </HeaderStyle>
<ItemStyle   HorizontalAlign= "Center "> </ItemStyle>
</asp:EditCommandColumn>
<asp:ButtonColumn   Text= "&lt;div       onclick=&quot;return       confirm( '确定要删除这条记录吗? ')&quot;&gt;删除&lt;/div&gt; "
HeaderText= "删除 "   CommandName= "Delete ">
<HeaderStyle   HorizontalAlign= "Center "   ForeColor= "White "   BackColor= "#72AED8 "> </HeaderStyle>
<ItemStyle   HorizontalAlign= "Center "> </ItemStyle>
</asp:ButtonColumn>
</Columns>
<PagerStyle   NextPageText= "下一页 "   PrevPageText= "上一页 "> </PagerStyle>
</asp:datagrid>

------解决方案--------------------

Private Sub dagGroup_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dagGroup.PageIndexChanged
dagGroup.CurrentPageIndex = e.NewPageIndex
binddata() ' ' ' ' ' ' ' ' ' ' ' '
End Sub
------解决方案--------------------
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
//如果你有数据绑顶函数就加这行 BindGrid();
}
------解决方案--------------------
以上的对
------解决方案--------------------
指定当前页,绑定数据。结贴呀!