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

paging

2 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dip
Top achievements
Rank 1
Dip asked on 20 Nov 2008, 02:00 AM

 

protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)

 

{

RadGrid2.CurrentPageIndex = e.NewPageIndex;

RadGrid2.DataBind();

RadGrid1.MasterTableView.Items[0].Selected =

true;

 

RadGrid2.MasterTableView.Items[0].Selected =

true;

 

}



I have this code ...Basically when I change the page index of RadGrid1 ...The Page in RadGrid2 should also change ...It work perfectly..But I also wanted to select the top row ...The one that I have block doesn't work..Why?Any alternate way of doing things...

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Nov 2008, 10:53 AM
Hello Dip,

You can try the following code to select the first item of both the grids when the page index is changed in the first grid. Here, the new page index is assigned to a variable which is globally accessible and initialized.
cs:
protected void Page_PreRender(object sender, EventArgs e) 
    {         
       if (index!=-1 && RadGrid1.SelectedIndexes.Count == 0 && RadGrid2.SelectedIndexes.Count == 0) 
        { 
                RadGrid1.SelectedIndexes.Add(0); 
                RadGrid2.SelectedIndexes.Add(0);            
        } 
    } 
 
 int index = -1 ; 
 protected void RadGrid1_PageIndexChanged(object source, GridPageChangedEventArgs e) 
    {         
        RadGrid2.CurrentPageIndex = e.NewPageIndex; 
        RadGrid2.Rebind(); 
        index = e.NewPageIndex;    
        
    } 

Thanks
Princy.
0
Dip
Top achievements
Rank 1
answered on 20 Nov 2008, 01:39 PM
Thanks,,,,,,
Tags
Grid
Asked by
Dip
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dip
Top achievements
Rank 1
Share this question
or