<%@ Page Language="VB" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub
Private Sub BindData()
Dim conn As SqlConnection = New SqlConnection("server=�localhost�;
trusted_connection=true; Database=�Northwind�")
Dim cmd As SqlCommand = New SqlCommand("Select * From Customers", conn)
conn.Open()
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "Customers")
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End Sub
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
DataGrid1.CurrentPageIndex = e.NewPageIndex
BindData()
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="DataGrid1" runat="server" AllowPaging="True"
OnPageIndexChanged="DataGrid1_PageIndexChanged"></asp:DataGrid>
</form>
</body>
</html>

Last edited Sep 16, 2010 at 8:36 AM by johnnykobeis, version 1

Comments

No comments yet.