asp: literal> td> tr> Tbody> table> td> tr> tbody> table> body> html> DataGridPage.aspx.cs
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.ui.WebControls; use system.web.ui.htmlcontrols;
Summary description of Namespace NetCRM {/// /// DataGridPage. /// summary> public class DataGridPage: System.Web.UI.Page {protected System.Web.UI.WebControls.Literal Literal1; protected System.Web.UI.WebControls.Literal Literal2; protected System.Web.UI. WebControls.DataGrid DataGrid1; Private Void Page_load (Object Sender, System.Eventargs E) {// Place the user code here to initialize the page if (! Ispostback) {bindgrid ();}}
private void BindGrid () {string connstring = "Server = .; Database = NorthWind; User Id = sa; Password =;"; string sql = "Select * from Orders"; SqlConnection conn = new SqlConnection (connstring); conn.Open (); DataSet DS = New DataSet (); SqlDataAdapter SQLADAPTER = New SqlDataAdapter (SQL, CONN); SQLADAPTER.FILL (DS, "Users"); DataView DataView = New DataView (); DataView = DS.Tables [0]. DefaultView;
DataGrid1.datasource = ds.tables [0] .defaultView; dataGrid1.database; string cpage; int pageSize = 10; int currentpage; int pagecount; int NumResults = 0;
IF (Request.QueryString ["Page" == NULL) {CPAGE = "1";} else {cpage = request.queryString ["page"]. Tostring ();} try {currentpage = int32.parse (CPAGE) } Catch {currentpage = 1;}
NumResults = 0; int start = (int); int to = (int); if (start <= 0) start = 0;
numResults = dataview.Count; int a1 = 0; pageCount = Math.DivRem (numResults, pageSize, out a1); if (a1> 0) {pageCount ;} if (currentPage> pageCount || currentPage <= 0) {currentPage = 1;}} {to = dataview.count;} // create one datatable with one column. DataTable myTable = new data ("myTable"); myTable = dataview.table.clone ();
// Datacolumn Colitem1 = New Datacolumn ("Name", Type.gettype ("System.String")); // Datacolumn Colitem2 = New Datacolumn ("Types", Type.gettype ("System.String")); //// Datacolumn colitem3 = new datacolumn ("vendor", type.gettype ("system.string")); //mytable.columns.add(COLITEM1); //mytable.columns.add(Colitem2); //mytable.columns. Add (colitem3); // add row datarow newrow; for (int i = start; i
/// /// Generate a page navigation bar. /// summary> string strnav = ""; int endpage; if (currentpage> 1) {strnav = " ";} if (CurrentPage> 11) {strnav =" " i.tostring () "";}}} f ((CurrentPage 10) " PageCount.toString () " ";} if (currentpage ";} literal1.text = strnav; literal2.text =" Total " NumResults.tostring () 条 供 供 供 信息, current Display " 1) .tostring () " - " TO.TOSTRING () "Bar, Total" PageCount.toString () "Page";
#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} /// /// Designer Supports the required method - Do not use the code editor to modify the // / this method. /// summary> private void initializecomponent () {this.load = new system.eventhandler (this.page_load);} #ENDREGON}}
转载请注明原文地址:https://www.9cbs.com/read-24632.html