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

Add previous and next button outside of grid

2 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hitesh
Top achievements
Rank 1
Hitesh asked on 02 Apr 2012, 01:51 AM
Hi,

I'm trying to add a previous and next button outside of the grid. I'm having some problems doing that. Can somebody give me some direction on how this is done?

Functionality:
If next button is pressed, the next record after the selected record is picked.
If previous button is pressed, the previous record from the selected record is picked.

Thank you,
-Tesh

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Apr 2012, 07:40 AM
Hello Hitesh,

protected void Button1_Click(object sender, EventArgs e)
   {
       // previuos
      
       int curentindex = 0;
       if (RadGrid1.SelectedItems.Count > 0)
       {
           curentindex = RadGrid1.SelectedItems[0].ItemIndex;
 
           if (curentindex > 0)
           {
               curentindex--;
 
               foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
               {
                   if (item.ItemIndex == curentindex)
                       item.Selected = true;
                   else
                       item.Selected = false;
               }
           }
       }
 
       
   }
   protected void Button2_Click(object sender, EventArgs e)
   {
       //next
       
       int curentindex = 0;
       if (RadGrid1.SelectedItems.Count > 0)
       {
           curentindex = RadGrid1.SelectedItems[0].ItemIndex;
 
           if (curentindex < RadGrid1.MasterTableView.Items.Count - 1)
           {
               curentindex++;
 
               foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
               {
                   if (item.ItemIndex == curentindex)
                       item.Selected = true;
                   else
                       item.Selected = false;
               }
           }
       }
   }


Thanks,
Jayesh Goyani
0
Hitesh
Top achievements
Rank 1
answered on 02 Apr 2012, 06:02 PM
Jayesh,

Thank you for your help.  I really appreciate it.  But I have another problem now.  I created a new thread for it:

http://www.telerik.com/community/forums/aspnet-ajax/grid/scroll-bar-does-not-move-with-selected-item.aspx

-Hitesh
Tags
Grid
Asked by
Hitesh
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Hitesh
Top achievements
Rank 1
Share this question
or