C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







pagin in the datagrid.


Posted Date: 14 Apr 2008    Resource Type: Code Snippets    Category: VB.NET Syntax

Posted By: Abhishek Arya       Member Level: Diamond
Rating:     Points: 10



Here is a small example of the pagin in the datagrid. it will show the pagin in the form of page number at the bottom of the gird.


Here is a small example of the pagin in the datagrid. it will show the pagin in the form of page number at the bottom of the gird.


<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<title>DotNetJunkies.com - Paging in the DataGrid Part 1</title>
<script runat="server" language="VB">
Sub Page_Load(Source As Object, E As EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub

Sub BindData()
Dim ds As New DataSet
Dim sda As SqlDataAdapter
Dim strSQL As String
Dim strCon As String

strSQL = "SELECT CompanyName, ContactName, " & _
" ContactTitle, Phone, Fax FROM Customers " & _
" ORDER BY CompanyName" < BR> strCon="server=localhost;database=Northwind;uid=sa;pwd=;"

sda = New SqlDataAdapter(strSQL, strCon)
sda.Fill(ds, "Customers")

myDataGrid.DataSource = ds.Tables("Customers")
myDataGrid.DataBind()
End Sub

Sub myDataGrid_PageChanger(Source As Object, _
E As DataGridPageChangedEventArgs)
' Set the CurrentPageIndex before binding the grid
myDataGrid.CurrentPageIndex = E.NewPageIndex
BindData()
End Sub
</script>
<style>
.DataGrid {font:x-small Verdana, Arial, sans-serif}
</style>
</head>
<body>
<form runat="server" method="post">
<asp:DataGrid runat="server" id="myDataGrid"
Border="0"
Cellpadding="4"
Cellspacing="0"
AlternatingItemStyle-BackColor="#EFEFEF"
ShowHeader="True"
CssClass="DataGrid"
HeaderStyle-BackColor="Black"
HeaderStyle-ForeColor="White"
HeaderStyle-Font-Bold="True"
AllowPaging="True"
PageSize="10"
PagerStyle-Mode="NumericPages"
OnPageIndexChanged="myDataGrid_PageChanger"
/>
</form>
</body>
</html>







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How To Clear OR Remove Session Values
Previous Resource: Insert a new row in the database using VBScript
Return to Discussion Resource Index
Post New Resource
Category: VB.NET Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference call

Contact Us    Privacy Policy    Terms Of Use