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

ElementExporting Event - access data item

0 Answers 57 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Justin Lee
Top achievements
Rank 1
Justin Lee asked on 21 Nov 2012, 05:34 PM
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 + "***";
    }
  }
}

No answers yet. Maybe you can help?

Tags
TreeListView
Asked by
Justin Lee
Top achievements
Rank 1
Share this question
or