This is a migrated thread and some comments may be shown as answers.

How to Set Grid Paging no of Records Drop down options Programatically

2 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sambhav Jain
Top achievements
Rank 1
Sambhav Jain asked on 12 May 2010, 06:14 AM
Hi,
    I have requirement in telerik Rad grid.
Scenario: My Grid default page size should be 50.So the other options available are 10,20.In total it will be 10,20,50.I want to add 100 to these options.That is i want drop down options like this 10,20,50,100.
How can I acheive this please help me.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 12 May 2010, 06:51 AM
Hello Sambhav,

The following code snippet will do the trick.

C#:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)   
{   
    if (e.Item is GridPagerItem)   
    {   
        RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");   
  
        PageSizeCombo.Items.Clear();   
        PageSizeCombo.Items.Add(new RadComboBoxItem("10"));   
        PageSizeCombo.FindItemByText("10").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);   
        PageSizeCombo.Items.Add(new RadComboBoxItem("20"));   
        PageSizeCombo.FindItemByText("20").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);   
        PageSizeCombo.Items.Add(new RadComboBoxItem("50"));   
        PageSizeCombo.FindItemByText("50").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);   
        PageSizeCombo.Items.Add(new RadComboBoxItem("100"));   
        PageSizeCombo.FindItemByText("100").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);   
  
        PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;   
    }   
}  

Cheers,
Princy.
0
Sambhav Jain
Top achievements
Rank 1
answered on 12 May 2010, 07:08 AM
Hi Princy,
            Its worked ,Thanks a lot.
Tags
Grid
Asked by
Sambhav Jain
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Sambhav Jain
Top achievements
Rank 1
Share this question
or