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

[Solved] Export Fails With Group By Including Null Value

2 Answers 173 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.
Ryan Morgan
Top achievements
Rank 1
Ryan Morgan asked on 05 Oct 2009, 10:18 PM
I have a SL3 Telerik grid that allows grouping and exporting that grouped grid.

If I export that grid when it is grouped by a column that has a null value, I get the following exception:

---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------

System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.ExportExtensions.GetRowValues(GridViewDataControl source, IList`1 records, StringBuilder& builder, ExportFormat format)
   at Telerik.Windows.Controls.ExportExtensions.ToHtml(GridViewDataControl source, IList`1 records, Boolean includeHeader)
   at Telerik.Windows.Controls.ExportExtensions.ToHtml(GridViewDataControl source, Boolean includeHeader)
   at ProcessManager.Silverlight.MainPage.ExportGridDataButton_Click(Object sender, RoutedEventArgs e)
   at System.Windows.RoutedEventHandler.Invoke(Object sender, RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
Message: Object reference not set to an instance of an object.
StackStrace:    at Telerik.Windows.Controls.ExportExtensions.GetRowValues(GridViewDataControl source, IList`1 records, StringBuilder& builder, ExportFormat format)
   at Telerik.Windows.Controls.ExportExtensions.ToHtml(GridViewDataControl source, IList`1 records, Boolean includeHeader)
   at Telerik.Windows.Controls.ExportExtensions.ToHtml(GridViewDataControl source, Boolean includeHeader)
   at ProcessManager.Silverlight.MainPage.ExportGridDataButton_Click(Object sender, RoutedEventArgs e)
   at System.Windows.RoutedEventHandler.Invoke(Object sender, RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------


Here is my code to export the grid data:


---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------

string content = grid.ToHtml( true );

 

 

string extension = "xls";

 

 

SaveFileDialog dialog = new SaveFileDialog()

 

{

DefaultExt = extension,

Filter =

String.Format( "{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel files" ),

 

FilterIndex = 1

};

 

if( dialog.ShowDialog() == true )

 

{

 

using( Stream stream = dialog.OpenFile() )

 

{

 

Byte[] bytes = System.Text.Encoding.UTF8.GetBytes( content );

 

stream.Write( bytes, 0, bytes.Length );

stream.Close();

}

}

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 06 Oct 2009, 08:01 AM
Hello Ryan,

Fixed immediately! You can contact the support to request our latest build. I've added 1000 Telerik points to your account.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ryan Morgan
Top achievements
Rank 1
answered on 07 Oct 2009, 04:13 AM
Wow. That's pretty amazing support!

I'll make sure to save this for the next time I deal with a client that had a bad experience with DevExpress or Infragistics and resists using third party components!

Best,

Ryan Morgan
www.ArrowDesigns.com
Tags
GridView
Asked by
Ryan Morgan
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Ryan Morgan
Top achievements
Rank 1
Share this question
or