Thursday, December 8, 2011

Paging in Gridview If we dont set Datasource

Declare the dataset as
Shared ds as new Dataset

Bind the gridview using dataset as

Gridview1.Datasource = ds.Table(0)
Gridview1.DataBind()

After that make the AllowPaging = True

Then we have to handle  PageIndexChanging event as bel;ow

Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
        Try
            GridView1.PageIndex = e.NewPageIndex
            GridView1.DataSource = dsTmp.Tables(0)
            GridView1.DataBind()
        Catch ex As Exception

        End Try
    End Sub

No comments: