The stored procedure is changed from the BiGeagle forum paging program. Please criticize! :) Select.aspx
-------------------------------------------------- ------------------------------
<% @ Page language = "c #"%> <% @ Import namespace = "system.data"%> <% @ import namespace = "system.data.sqlclient"%>
protected void Page_Load (Object sender, EventArgs e) {int intPageNo, intPageSize, intPageCount; intPageSize = 25; if (Request [ "CurrentPage"] == null) {intPageNo = 1;} else {intPageNo = Int32.Parse (Request [ "CurrentPage"]);} SqlConnection mySqlConnection = new SqlConnection ( "server = (local); Database = test; user id = sa; password ="); SqlCommand mySqlCommand = new SqlCommand ( "up_GetTopicList", mySqlConnection); mySqlCommand.CommandType = CommandType.StoredProcedure; SqlParameter workParm; // search table field to "," separated by workParm = mySqlCommand.Parameters.Add ( "@ a_TableList", SqlDbType.VarChar, 200); mySqlCommand.Parameters [ "@ a_TableList"]. Value = "Offerid, Type, Offertime"; // Search Table Name Work PARM = mysqlcommand.Parameters.add ("@ a_tablename", sqldbtype.varchar, 30); mysqlcommand.parameters ["@ a_tablename"]. Value = "offer"; // Search condition, such as "SELECT * from aa where a = 1 and b = 2 and c = 3 "Conditions" WHERE A = 1 and b = 2 and c = 3 "Workparm = mysqlcommand.Parameters.add (" @ a_selectwhere ", SqldbType.varchar, 500); mysqlcommand.parameters ["@a_selectwhere"]. value = "where type = 'idl'"; // table main key field name,
It must be int type workparm = mysqlcommand.parameters.add ("@ a_selectorderid", sqldbtype.varchar, 50); mysqlcommand.parameters ["@ a_selectorderid"]. Value = "offerid"; // Sort, you can use multi-field sorting but The primary key field must be in the front WorkParm = mysqlcommand.parameters.add ("@ a_selectorder", sqldbtype.varchar, 50); mysqlcommand.parameters ["@ a_selectorder"]. Value = "Order by offerid desc"; // Page No. Workparm = mySqlCommand.Parameters.Add ( "@ a_intPageNo", SqlDbType.Int);. mySqlCommand.Parameters [ "@ a_intPageNo"] Value = intPageNo; // page shows the number workParm = mySqlCommand.Parameters.Add ( "@ a_intPageSize", Sqldbtype.int); mysqlcommand.parameters ["@ a_intpagesize"]. Value = intPagesize; // Total number of records (stored procedure output parameters) Workparm = mysqlcommand.Parameters.add ("@ recordcount", sqldbtype.int); Workparm. Direction = parameterdirection.output; // Current page record number (stored procedure return value) Workparm = mysqlcommand.Parameters.add ("Rowcount", SqldbType.It); Workparm.Direction = parameterDirection.ReturnValue;
mySqlConnection.Open (); Repeater.DataSource = mySqlCommand.ExecuteReader (); Repeater.DataBind (); mySqlConnection.Close (); Int32 RecordCount = (Int32) mySqlCommand.Parameters [ "@ RecordCount"] Value;. Int32 RowCount = ( int32) mySqlCommand.Parameters [ "RowCount"] Value;. LabelRecord.Text = RecordCount.ToString (); LabelRow.Text = intPageNo.ToString (); intPageCount = RecordCount / intPageSize; if ((RecordCount% intPageSize)> 0) intPageCount = 1; LabelPage.Text = intPageCount.ToString (); if (intPageNo> 1) {HLFistPage.NavigateUrl = "? select.aspx CurrentPage = 1";? HLPrevPage.NavigateUrl = String.Concat ( "select.aspx CurrentPage = ",", INTPAGENO-1);} else { HLFistPage.NavigateUrl = ""; HLPrevPage.NavigateUrl = ""; //HLFistPage.Enabled = false; //HLPrevPage.Enabled = false;} if (intPageNo } Else {hlnextPage.navigateURL = ""; hlendpage.navigateURL = ""; //hlnextpage.enabled=false; //hlendpage.enabled=false;}} script>