在下边的事件中
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
bindnew();
}
bindnew()为函数,重新绑定数据源,须自己写,和Page_Load你在中的一样
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
bindnew();
}
bindnew()为函数,重新绑定数据源,须自己写,和Page_Load你在中的一样
解决方案 »
- 自定义控件中颜色属性在vs环境下预览的问题
- JS报错:对象不支持此属性或方法 '$' 未定义
- 有没有谁搞过vmware?我建了一个虚拟机,装的是windows server 2003 我现在想组网,使我的物理机和虚拟机能够连接,如何做啊?
- 谁能说说目前asp.net2.0最好的url重写代码或组件?
- 操它妈的VS2005(发布网站前用轻量服务器运行OK,发布后就OVER了。)
- 简单问题,指点一下
- asp.net程序原先运行问题,系统改装成目录服务器后,调试出错,提示信息为"无法调试,灾难性故障",请问高手,why?
- .NET 动态删除表格的行问题
- 写入oracle数据库是乱码!急
- 请教如何在asp.net页面显示asp.net标签!
- 关于换行问题
- 一般控制Web访问流量采用什么方法,有没有相关文档。
public void changegridpage(object sender, DataGridPageChangedEventArgs objargs)
{
//此处是datagrid分页响应过程
DataGrid1.CurrentPageIndex = objargs.NewPageIndex;
binddatagrid();
}
public void sortrows(object sender, DataGridSortCommandEventArgs objargs)
{
//此处是datagrid排序响应过程
sortorder = objargs.SortExpression.ToString();
binddatagrid();
}
public void binddatagrid()
{
//此处是gatagrid的数据绑定过程
DataGrid1.PageSize = 5;
DataGrid1.PagerStyle.Mode = PagerMode.NumericPages;
string varsql = "select * from telrecord";
myconnclass myclass =new conndbdll.myconnclass();
string mytable="mytable";
DataSet mydataset=myclass.DataAdapter(varsql,mytable);
DataView mydataview = new DataView(mydataset.Tables["mytable"]);
//mydataview.Sort = sortorder;
DataGrid1.DataSource = mydataview;
DataGrid1.DataBind();
}
datagrid1.currentpageindex=i;
datagrid1.datasource=ds;
datagrid1.databind;
private void dgResult_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
this.dgResult.CurrentPageIndex = e.NewPageIndex;
DataGrid重新绑定代码
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 21px; POSITION: absolute; TOP: 19px" runat="server" Width="480px" Height="133px" BorderStyle="None" BorderWidth="1px" BorderColor="#CC9966" BackColor="White" CellPadding="4" PageSize="3" AllowPaging="True">
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></HeaderStyle>
<PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC" Mode="NumericPages"></PagerStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
</asp:DataGrid>
</form>
</body>
</HTML>Imports System
Imports System.Data
Imports System.Data.SqlClientPublic Class PagedGrid
Inherits System.Web.UI.Page
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid#Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
BindGrid()
End If
End Sub Private Sub BindGrid()
Dim cnn As SqlConnection
Dim da As SqlDataAdapter
Dim ds As New DataSet() cnn = New SqlConnection(ConfigurationSettings.AppSettings().Item("ConnectionString"))
da = New SqlDataAdapter("select lastname,firstname,city from employees", cnn)
da.Fill(ds, "employees") DataGrid1.DataSource = ds
DataGrid1.DataMember = "employees"
DataGrid1.DataBind() End Sub Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged End Sub Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
DataGrid1.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
End Class