Paging In Telerik Radgrid

Paging  In Telerik Radgrid

For pagination in Radgrid we have to set two properties.
1)      AllowPaging="true"
2)      <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>

Step 1: Design web Form .aspx page


<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" AllowPaging="true" PageSize="8"  Width="50%" PagerStyle-AlwaysVisible="true"
                GridLines="None" AutoGenerateColumns="false"
                OnNeedDataSource="RadGrid1_NeedDataSource">
                  <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                <HeaderStyle HorizontalAlign="Left" />
                <MasterTableView DataKeyNames="name" AutoGenerateColumns="false">
                    <NoRecordsTemplate>No records found.</NoRecordsTemplate>

                    <Columns>
                        <telerik:GridBoundColumn HeaderText="Name" DataField="Name" />
                        <telerik:GridBoundColumn HeaderText="Amount" DataField="Amount" />
                        <telerik:GridBoundColumn HeaderText="Phone" DataField="Phone" />
                    </Columns>


                </MasterTableView>
            </telerik:RadGrid>


Step 2: Logic on .Cs page


protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("Name");
        dt.Columns.Add("Amount");
        dt.Columns.Add("Phone");


        dt.Rows.Add("Kandy", "12", "8802***2564");
        dt.Rows.Add("Sam", "25", "545502*2544");
        dt.Rows.Add("Izhar", "32", "95802*2452");
        dt.Rows.Add("Vineet", "10.2", "88022564***");


        dt.Rows.Add("Kandy", "0.12", "8802***2564");
        dt.Rows.Add("Sam", "12", "545502*2544");
        dt.Rows.Add("Izhar", "215", "95802*2452");
        dt.Rows.Add("Vineet", "11.00", "88022564***");
        dt.Rows.Add("Kandy", "0.12", "8802***2564");
        dt.Rows.Add("Sam", "12", "545502*2544");
        dt.Rows.Add("Izhar", "215", "95802*2452");
        dt.Rows.Add("Vineet", "11.00", "88022564***");
        dt.Rows.Add("Kandy", "0.12", "8802***2564");
        dt.Rows.Add("Sam", "12", "545502*2544");
        dt.Rows.Add("Izhar", "215", "95802*2452");
        dt.Rows.Add("Vineet", "11.00", "88022564***");

        RadGrid1.DataSource = dt;
       
    }

It Will look like :-



Comments

Popular posts from this blog

Create and save QR code in asp.net with C#

Change text of RadGrid Header Dynamically

Telerik Radwindow Open on Button Click