- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
Internet Applications in .NET
Internet Applications Create Denso QR Bar Code In Visual Studio .NET Using Barcode drawer for .NET framework Control to generate, create Denso QR Bar Code image in VS .NET applications. www.OnBarcode.comQuick Response Code Recognizer In Visual Studio .NET Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.com Display a page. Sub ShowPage(ByVal pageNum As Integer) Keep the page number in valid range. pageNum = Math.Max(0, Math.Min(pageNum, dgrTitles.PageCount - 1)) Enforce the new page number and bind the control. dgrTitles.CurrentPageIndex = pageNum BindDataGrid() Update button state. btnFirst.Enabled = (pageNum > 0) btnPrevious.Enabled = (pageNum > 0) btnNext.Enabled = (pageNum < dgrTitles.PageCount - 1) btnLast.Enabled = (pageNum < dgrTitles.PageCount - 1) Display the current page number (1-based). txtPage.Text = (pageNum + 1).ToString End Sub Draw Barcode In .NET Using Barcode creation for Visual Studio .NET Control to generate, create bar code image in .NET framework applications. www.OnBarcode.comBarcode Reader In .NET Using Barcode scanner for .NET framework Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comWhen you re doing default paging using either default or custom navigation buttons you must bind the DataGrid control to a DataView or DataTable object, as you d do if pag ing were disabled so that the control can use the CurrentPageIndex property to display only the requested page. The demo application reduces database activity by creating the DataSet object the first time the page is requested and storing it in a Session variable. Here s the code that does the binding and provides support for column sorting as well: QR Code ISO/IEC18004 Printer In Visual C# Using Barcode printer for Visual Studio .NET Control to generate, create Quick Response Code image in Visual Studio .NET applications. www.OnBarcode.comQR Code 2d Barcode Generation In VS .NET Using Barcode drawer for ASP.NET Control to generate, create QR Code 2d barcode image in ASP.NET applications. www.OnBarcode.com Bind the DataGrid control. Sub BindDataGrid() Retrieve the DataSet from the session variable. Dim ds As DataSet = DirectCast(Session( DataSet ), DataSet) Read data from database if this is the first time you do it. If ds Is Nothing Then Dim cn As New OleDbConnection(BiblioConnString) cn.Open() Read data from Titles table, plus the publisher s name. Dim sql As String sql = SELECT Titles.*, Publishers.Name As PubName FROM Titles _ & INNER JOIN Publishers ON Titles.PubId=Publishers.PubId" Dim da As New OleDbDataAdapter(sql, cn) ds = New DataSet() da.Fill(ds, Titles ) cn.Close() Store the DataSet in a Session variable. Session( DataSet ) = ds End If Make Quick Response Code In Visual Basic .NET Using Barcode encoder for VS .NET Control to generate, create Quick Response Code image in .NET framework applications. www.OnBarcode.comMake Barcode In VS .NET Using Barcode maker for Visual Studio .NET Control to generate, create bar code image in .NET framework applications. www.OnBarcode.com Get a DataView object sorted on the required sort expression.
DataBar Creator In .NET Using Barcode creation for Visual Studio .NET Control to generate, create GS1 DataBar Limited image in Visual Studio .NET applications. www.OnBarcode.comDraw Barcode In .NET Using Barcode printer for VS .NET Control to generate, create barcode image in Visual Studio .NET applications. www.OnBarcode.comDim dv As DataView = ds.Tables( Titles ).DefaultView
Matrix 2D Barcode Creation In .NET Framework Using Barcode generation for VS .NET Control to generate, create Matrix 2D Barcode image in .NET applications. www.OnBarcode.comUSPS PLANET Barcode Generator In VS .NET Using Barcode printer for Visual Studio .NET Control to generate, create Planet image in .NET applications. www.OnBarcode.comdv.Sort = dgrTitles.Attributes( SortExpr ) Making PDF417 In C#.NET Using Barcode maker for .NET Control to generate, create PDF417 image in .NET framework applications. www.OnBarcode.comBarcode Creation In Java Using Barcode generation for Java Control to generate, create barcode image in Java applications. www.OnBarcode.comdgrTitles.DataSource = dv
Create UCC - 12 In None Using Barcode generation for Online Control to generate, create UPCA image in Online applications. www.OnBarcode.comPaint GS1 - 13 In Objective-C Using Barcode generation for iPad Control to generate, create GS1 - 13 image in iPad applications. www.OnBarcode.com Do the data binding.
EAN / UCC - 13 Generator In Objective-C Using Barcode generation for iPhone Control to generate, create GTIN - 128 image in iPhone applications. www.OnBarcode.comBarcode Reader In VS .NET Using Barcode Control SDK for ASP.NET Control to generate, create, read, scan barcode image in ASP.NET applications. www.OnBarcode.comdgrTitles.DataBind() Encode UPC Code In None Using Barcode printer for Office Excel Control to generate, create UCC - 12 image in Microsoft Excel applications. www.OnBarcode.comBarcode Scanner In Java Using Barcode Control SDK for Eclipse BIRT Control to generate, create, read, scan barcode image in BIRT reports applications. www.OnBarcode.comEnd Sub Private Sub dgrTitles_SortCommand(ByVal source As Object, _ ByVal e As DataGridSortCommandEventArgs) Handles dgrTitles.SortCommand 25: Web Forms Data Binding
Extract current sort column and order.
Dim currSortExpr As String = dgrTitles.Attributes( SortExpr ) Dim newSortExpr As String = e.SortExpression
If the sort field is the same, just reverse the direction.
If Not (currSortExpr Is Nothing) AndAlso _ currSortExpr.ToString = e.SortExpression Then newSortExpr &= DESC" End If Remember the new sort expression and show the first page.
dgrTitles.Attributes( SortExpr ) = newSortExpr
ShowPage(0) End Sub
Default paging has a great shortcoming: you must load all the data in a DataTable or DataView object to let the DataGrid control select only the rows that belong to the current page. This approach might be OK when the data source contains a few hundred rows, but it won t work in real-world applications that manage thousands (or even millions) of rows. In cases like these, custom paging is the only reasonable solution. You activate custom paging by setting both the AllowPaging and the AllowCustomPag ing properties to True. You then assign the total number of rows to the VirtualItemCount property so that the control can correctly evaluate the PageCount value. You can use default buttons or provide your own. Unlike all the samples shown previously, when in custom paging mode you bind the DataGrid control to a data source that contains only the data you want to display in the current page. Fortunately, you already know how to page through a large resultset by using the DataAdapter s Fill method. Thanks to the high modularity of the code written so far, implementing custom paging is just a matter of replacing the BindDataGrid pro cedure with a new version that takes the CurrentPageIndex and PageSize properties into account. The following code also takes the current sort order into account: Notice that when doing custom paging, you implement sorting by means of an ORDER BY clause in the SQL query so that you can then extract the correct page from the sorted resultset: Sub BindDataGrid() Open the connection. Dim cn As New OleDbConnection(BiblioConnString) cn.Open() If necessary, initialize VirtualItemCount with number of records. If Not Me.IsPostBack Then Dim cmd As New OleDbCommand( SELECT COUNT(*) FROM Titles", cn) dgrTitles.VirtualItemCount = CInt(cmd.ExecuteScalar) End If Prepare to read from Titles table plus Name of publisher. Dim sql As String = SELECT Titles.*, Publishers.Name As PubName FROM _ & Titles INNER JOIN Publishers ON Titles.PubId=Publishers.PubId" Append sort expression, if there is one. Part VI:
|
|