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

[Solved] Extract - throwing errors or poorly formatted

2 Answers 76 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
MB
Top achievements
Rank 1
MB asked on 03 Aug 2011, 09:26 PM
It seems since upgrading to a newer set of Q2 dlls (RadControls_for_Silverlight_4_2011_1_0419_Dev_hotfix or beyond - and the same also happens in Q3) we are getting errors with our grid extract.

When a null value is hit, we get an error.  I can see why from our code (null reference), however even after handling this, the extract succeeds but simply has [#Error] in all of the cells (Excel).

We are using extract differently in another area in the app and it does not seem to have been impacted.

Offending Code:

private static void radResult_ElementExporting(object sender, GridViewElementExportingEventArgs e)
{
    if (e.Element == ExportElement.Cell)
    {
        var column = e.Context as GridViewDataColumn;
        if (column == null) return;
        Binding binding = column.DataMemberBinding;
        if (binding == null) return;
        IValueConverter converter = binding.Converter;
        if (converter == null) return;
        object value = e.Value;
        Type type = e.Value.GetType(); // <== this suddenly started throwing errors after update
        object parameter = binding.ConverterParameter;
        CultureInfo culture = binding.ConverterCulture;
        e.Value = binding.Converter.Convert(value, type, parameter, culture);
    }
}

Even if we handle the exception (check for null e.Value and return) then then output is bad ([#Error] in every cell that is not null) - the attached file output shows this.

2 Answers, 1 is accepted

Sort by
0
MB
Top achievements
Rank 1
answered on 03 Aug 2011, 09:58 PM

Ok, I think I may have figured it out.  The [#Error] is coming from the converter - so that's no problem (oops).

What it looks like is that there was a change in behaviour - that now the e.Value of GridViewElementExportingEventArgs is already the CONVERTED value, whereas before it was the pre-converted value or datacontext.

is this correct?



0
Ivan Ivanov
Telerik team
answered on 09 Aug 2011, 09:54 AM
Hello Mb,

Yes. In the current version of RadControls for Silverlight the Value property of  GridViewElementExportingEventArgs contains the converted value, as expected.

Best wishes,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Tags
GridView
Asked by
MB
Top achievements
Rank 1
Answers by
MB
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Share this question
or