Access Command Items programmatically?

2 posts, 0 answers
  1. Chris
    Chris avatar
    4 posts
    Member since:
    Jan 2020

    Posted 21 Jan 2020 Link to this post

    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?

  2. Chris
    Chris avatar
    4 posts
    Member since:
    Jan 2020

    Posted 21 Jan 2020 in reply to Chris Link to this post

    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.

     

Back to Top