Live Chat Icon For mobile
Live Chat Icon

How to do Paging using DataGrid

Platform: ASP.NET| Category: DataGrid

<asp:DataGrid id='DataGrid1' AllowPaging =true PageSize =5 OnPageIndexChanged ='PageData' runat='server'></asp:DataGrid>

VB.NET


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	’Put user code to initialize the page here
	If Not Page.IsPostBack Then
		Binddata()
	End If
End Sub

Protected Sub PageData(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
	DataGrid1.CurrentPageIndex = e.NewPageIndex
	Binddata()
End Sub

Sub Binddata()
	’Populate the DataGrid using DataSet
End Sub

C#


private void Page_Load(object sender, System.EventArgs e)
{
	// Put user code to initialize the page here
	if(! Page.IsPostBack )
	{
		Binddata();
	}
}
		 
protected void PageData(Object source , System.Web.UI.WebControls.DataGridPageChangedEventArgs   e  )
{
	DataGrid1.CurrentPageIndex = e.NewPageIndex;
	Binddata();
}

void Binddata()
{
	//Populate the DataGrid using DataSet
}

Share with

Share on twitter
Share on facebook
Share on linkedin