Step 1:
Connect database and access any table to display in Gridview.
'Declare below code in Partial Class _Default
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim adp As SqlDataAdapter
Dim ds As DataSet
'write code at page_load event
con = New SqlConnection(ConfigurationManager.AppSettings("cn"))
Dim sql As String
sql = "select * from tbl_logo_info"
cmd = New SqlCommand(sql, con)
adp = New SqlDataAdapter(cmd)
ds = New DataSet()
adp.Fill(ds, "tbl_adminuser")
GridView1.DataSource = ds
GridView1.DataBind()
Step 2:
'write below code at pageindexchaging event
Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
GridView1.PageIndex = e.NewPageIndex
GridView1.DataBind()
End Sub
15 years ago
No comments:
Post a Comment