ElementExporting Event - access data item

1 posts, 0 answers
  1. Justin Lee
    Justin Lee avatar
    149 posts
    Member since:
    Dec 2009

    Posted 21 Nov 2012 Link to this post

    Hello,
    I have a TreeListView with a button to export to excel.  At the time of exporting, I'd like to modify cell content slightly, based on properties of the underlying data context of the grid row that is being exported. However, it appears that in the ElementExporting event, there is no way to get the current row (or DataContext of the current Row). 

    Any suggestions? 

    Here is an example of what I would like to do:
    private void grd_ElementExporting(object sender, GridViewElementExportingEventArgs e)
    {
      if (e.Element == ExportElement.Cell)
      {
        if (e.Context is GridViewDataColumn && ((GridViewDataColumn)e.Context).DisplayIndex == 0)
        {
           MyDataItem item = e.Item as MyDataItem;  //Pseudo code - this is what I would like to do...
           if (item.IsImportant)
             e.Value = "***" + e.Value + "***";
        }
      }
    }

Back to Top