hi!
i am using datagrid to display data. my aim is i want to give a paging bydefault in datagrid display 10 rows only. and 11th row onwards it goes to the 2nd page. please give a code to this.
thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anusha SrivastavaPosted Apr 1, 2010, 1:20 AM
Go to datagrid properties and assign PageButtonCount to 10,choose Mode,
And create event for PageIndexChanged in d properties.
like write OnPageIndexChanged="dgClient_PageIndexChanged" in the source.
Now write code in .cs file--
protected void dgClient_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
try
{
dgClient.CurrentPageIndex = e.NewPageIndex;
BindClientMaster();
}
catch (Exception ex)
{
throw ex;
}
Good Luck.
Amit ChoudharyPosted Apr 1, 2010, 1:44 AM
Here is the page index changed event
private void GridPageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
//Bind the DataGrid again with the Data Source
DataGrid1.DataSource = dataSet1;
DataGrid1.DataBind();
}
Please mark as answer if it helps.