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

Access Command Items programmatically?

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 21 Jan 2020, 08:04 PM

I have several RadGrids nested within their own ASP.NET UpdatePanels which are within an ASP.NET MultiView. I'm experiencing issues when it comes to exporting the RadGrid to Excel.

 

I know that the control needs to be registered to allow a PostBack, but I want to specifically register the in-built ExportToExcel button. In the ItemCreated event, I was able to identify GridCommandItems and register them as PostBackControls, but this is also registering the "Add New Record" button, causing a PostBack to occur if they click the "Add New Record" button.

 

Is there any way to programmatically identify JUST the "Export to Excel" Command Item?

1 Answer, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 21 Jan 2020, 09:06 PM

Spoke too soon :)

 

The literal name of the Export button is "ExportToExcelButton". In order to access the Export button, you have to do something similar to this (C#):

Button exampleName = (Button)e.Item.FindControl("ExportToExcelButton");

 

Took awhile to identify that the Export button had an ID of "ExportToExcelButton", as all attempts to access that (reviewing all properties, forcing a WriteLine of all of the IDs, ClientIDs, and UniqueIDs of the controls in the RadGrid, etc.) didn't reveal this information. Had to dig through several forum posts.

 

Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Share this question
or