自已弄得关于.NET分页显示(部分)
//PageSize第页显示记录数,NId下一页记号,PId前一页记号,np叛断是上下页.0上页;1下页
public void list_v(int PageSize, int PNo)
{
int NId = 0;
string list_str;
if (PNo ==1)
{list_str = "select top " + PageSize + " * from " + table_str + " order by log_id desc";}
else
{ list_str = "select top " + PageSize + " * from " + table_str + " where log_id not in( select top " + pagesize * (PNo - 1) + " " + "log_id from " + table_str + " order by log_id desc)" + "" + " order by log_id desc"; }
//Response.Write("OK");
Response.Write("<table cellSpacing='0' cellPadding='4' border='1' width='360' bordercolor='#6699FF'>");
Response.Write(" <tr bgColor='#dab4b4'>");
Response.Write(" <td width='30' align='center' bgcolor='#6699FF' bordercolor='#000080'>");
Response.Write(" <b><font color='#FFFFFF'>ID</font></b></td>");
Response.Write(" <td width='168' align='center' bgcolor='#6699FF' bordercolor='#000080'>");
Response.Write(" <b><font color='#FFFFFF'>名称</font></b></td>");
Response.Write(" <td width='42' align='center' bgcolor='#6699FF' bordercolor='#000080'>");
Response.Write(" <b><font color='#FFFFFF'>状态</font></b></td>");
Response.Write(" <td align='center' bgcolor='#6699FF' bordercolor='#000080'><b>");
Response.Write(" <font color='#FFFFFF'>维护</font></b></td>");
Response.Write(" </tr>");
conn_data t_conn = new conn_data();
t_conn.conn_open();
OleDbDataAdapter Adpt= new OleDbDataAdapter("select * from " + table_str, t_conn.conn);
DataSet Ds=new DataSet();
Adpt.Fill(Ds);
//DataTable mytable = Ds.Tables[0];
//Page_v_Load
OleDbCommand t_comm = new OleDbCommand();
//t_comm.Connection = t_conn.conn;
//t_comm.CommandText = "select count(*) from " + table_str;
//Page_v1.recordcount = int.Parse(t_comm.ExecuteScalar().ToString());//记录总数
Page_v1.recordcount = Ds.Tables[0].Rows.Count;
Page_v1.size = PageSize;//每页显示记录数
Page_v1.pno = PNo.ToString();//当前页
Page_v1.vstr = "work_log.aspx?"+ "&PNo=";//传递信息
t_comm.CommandText = list_str;
t_comm.Connection = t_conn.conn;
OleDbDataReader t_reader = t_comm.ExecuteReader();
//for (int i = 1; i <= Ds.Tables[0].Rows.Count; i++)
Response.Write("<tr>");
Response.Write("<td>" + Ds.Tables[0].Rows[0]["log_date"].ToString() + "</td>");
DataRow Row = Ds.Tables[0].Rows[0];//Rows[0],0表示行数;ROWS包含DATAROW,
Response.Write("<td>" + Row["log_ID"].ToString() + "</td>");
//Response.Write("<td>" + t_reader["LOG_DATE"].ToString() + "</td>");
//Response.Write("<td>" + "<a href=edit_other.aspx?id=" + t_reader[0].ToString() + "&TYPE=" + Request.QueryString["TYPE"] + "&PNo=" + PNo.ToString() + ">修改 </a>" + "<a href='#' onClick=del_is('del_other.aspx?id=" + t_reader[0].ToString() + "&TYPE=" + Request.QueryString["TYPE"] + "&PNo=" + PNo.ToString() + "','删除此条信息吗?')> 删除 </a>" + "</td>");
Response.Write("</tr>");
foreach (DataRow myRow in Ds.Tables[0].Rows)
{
foreach (DataColumn myColumn in Ds.Tables[0].Columns)
{
//String XXX = t_reader[3].ToString() == "1" ? "使用" : "停用";
Response.Write("<td>" + myRow[myColumn].ToString() + "</td>");
//Response.Write("<td>" + t_reader["LOG_INFO"].ToString() + "</td>");
//Response.Write("<td>" + t_reader["LOG_DATE"].ToString() + "</td>");
//Response.Write("<td>" + "<a href=edit_other.aspx?id=" + t_reader[0].ToString() + "&TYPE=" + Request.QueryString["TYPE"] + "&PNo=" + PNo.ToString() + ">修改 </a>" + "<a href='#' onClick=del_is('del_other.aspx?id=" + t_reader[0].ToString() + "&TYPE=" + Request.QueryString["TYPE"] + "&PNo=" + PNo.ToString() + "','删除此条信息吗?')> 删除 </a>" + "</td>");
//NId = Convert.ToInt32(t_reader[0].ToString());
}
Response.Write("</tr>");
Response.Write("<tr>");
Response.Write("<td>" + myRow["log_id"].ToString() + "</td>");
Response.Write("<td>" + myRow["log_info"].ToString() + "</td>");
//Response.Write("<td>" + t_reader["LOG_DATE"].ToString() + "</td>");
//Response.Write("<td>" + "<a href=edit_other.aspx?id=" + t_reader[0].ToString() + "&TYPE=" + Request.QueryString["TYPE"] + "&PNo=" + PNo.ToString() + ">修改 </a>" + "<a href='#' onClick=del_is('del_other.aspx?id=" + t_reader[0].ToString() + "&TYPE=" + Request.QueryString["TYPE"] + "&PNo=" + PNo.ToString() + "','删除此条信息吗?')> 删除 </a>" + "</td>");
Response.Write("</tr>");
}
//t_comm.
t_reader.Close();
t_conn.conn_close();
Response.Write("</table>");
}
========================================================================
在.net中,大数据量下的列表显示分页如何处理?
Private Sub DlistBind(ByVal SqlStr As String, ByVal Dlst As DataList, ByVal PgNum As Integer)< xmlnamespace prefix ="o" ns ="urn:schemas-microsoft-com:office:office" />
Dim Conn As New SqlConnection(ConnStr)
Conn.Open()
Dlst.DataSource = Tempi.DefaultView
Dlst.DataBind()
Conn.Close()
End Sub
Private Sub DlistBind(ByVal SqlStr As String, ByVal Dlst As DataList, ByVal PgNum As Integer)
Dim Conn As New SqlConnection(ConnStr)
Conn.Open()
Dim Adpt As New SqlDataAdapter(SqlStr, Conn)
Dim Ds As New DataSet
Adpt.Fill(Ds, "iTable")
Dim TotalRec As Integer = Ds.Tables.Item(0).Rows.Count
ShowTotalRec.Text = "当前共 " & TotalRec & " 部作品"
Dim TotalPage As Integer
If TotalRec < Pagec Then
TotalPage = 1
Else
If TotalRec Mod Pagec <> 0 Then
TotalPage = TotalRec \ Pagec + 1
Else
TotalPage = TotalRec / Pagec
End If
End If
ShowTotalPage.Text = TotalPage
ShowCurrentPage.Text = PgNum
Dim Tempi As DataTable = Ds.Tables.Item(0).Clone
Dim m, n As Integer
For m = (PgNum - 1) * Pagec To PgNum * Pagec - 1
If m < 0 Or m > Ds.Tables.Item(0).Rows.Count - 1 Then Exit For
Dim Row As DataRow = Tempi.NewRow()
For n = 0 To Ds.Tables.Item(0).Columns.Count - 1
Row(Ds.Tables.Item(0).Columns(n).ColumnName) = Ds.Tables.Item(0).Rows.Item(m).Item(n)
Next
Tempi.Rows.Add(Row)
Next
Dlst.DataSource = Tempi.DefaultView
Dlst.DataBind()
Conn.Close()
End Sub