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

Get Grid ID from event PageSizeChanged

1 Answer 167 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wired_Nerve
Top achievements
Rank 2
Wired_Nerve asked on 04 Apr 2014, 06:37 PM
I am trying to make a more generic method to attach to 3 grids on the same page and would like for the PageSizeChanged event to used by all three grids, but have the code inside the event figure out the grid that called the event...  I am sure this can be done, but I have not been able to drill down through the sender object to get the ID..

So I took this approach (Does it look safe enough?)...

var Sender = ((RadGrid)sender);
string GridName = Sender.ID;


public void Grid_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
       {
           
            
           //get the current page name
           string pageName = Path.GetFileNameWithoutExtension(Request.Path);
           string GridName = {Here is where I want to use sender to get the actual grid.id}
           int newPageSize = e.NewPageSize;
           var pagerHelper = new GridPagerSizeHelper();
           pagerHelper.saveSelectedPageSize(pageName, GridName, newPageSize, (User)Session["currentUser"]);
           var Nav = new  Common.MasterPages.Nav();
           Nav.ReloadUserPreferences((User)Session["currentUser"]);  // To avoid DB hit with each page load.
       }

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 05 Apr 2014, 03:50 AM
Hi,

Your approach is correct. The RadGrid ID can be simply obtained through  string GridId = ((RadGrid)sender).ID;
Please let me know if any concerns.

Thanks,
Shinu
Tags
Grid
Asked by
Wired_Nerve
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or