Tuesday, 21 May 2013

How to apply paging on Grid view control in asp.net

How to apply paging on Grid view control in asp.net


Step 1 : Create your website first and then create one .aspx page

Step 2 : Open that page and Drag and Drop GridView control from Toolbox Diaglog box

<asp:GridView ID="GridView1" runat="server">
</asp:GridView>



Step 3 : First set the property AllowPaging="True" .and also set the PageSize property as per developer requirement .

Step 4 : After adding property of grid view add server side event to handle paging .Set onPageindexChanging event of grid view and paste below code in that.


protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
        // Bind a'' the data gain to grid view
    }



Step 4 :This way you can use paging  with grid view.

Step 5 : Just run your application and see see the grid view


No comments:

Post a Comment

Thank you for your interest .