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

[Solved] NullReferenceException while clearing the grid columns

5 Answers 149 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.
Zainab Vora
Top achievements
Rank 1
Zainab Vora asked on 01 Sep 2010, 02:57 PM
Hello,

I am currently trying to clear columns from RadGridView. I am using  _grid.Columns.Clear() to do so.

It works fine if the columns count is 0.

However, If the grid contains columns, it crashes with a NullReferenceException. "Object reference not set to an instance of an object."
 
Is there any other way to clear all the columns?

Currently I am using Version 2010.1.603.1030.  Thank you.

5 Answers, 1 is accepted

Sort by
0
Zainab Vora
Top achievements
Rank 1
answered on 01 Sep 2010, 03:14 PM
at Telerik.Windows.Controls.GridViewSelectColumn.OnOwnerChanged(GridViewDataControl oldOwner, GridViewDataControl newOwner)
  at Telerik.Windows.Controls.GridViewColumn.set_DataControl(GridViewDataControl value)
  at Telerik.Windows.Controls.GridView.GridViewDataControl.UpdateGridViewDataControlReference(IList list, Boolean clear)
  at Telerik.Windows.Controls.GridViewColumnCollectionInternal.ClearItems()
  at System.Collections.ObjectModel.Collection`1.Clear()
  at CpgPortfolioAnalysis.GridView.GridView.UpdateColumns()


Above is the Stack trace.
0
Veselin Vasilev
Telerik team
answered on 01 Sep 2010, 03:53 PM
Hello Zainab Vora,

Do you modify the ItemsSource of the gridview before clearing the columns?

Can you try with a more recent version (preferable in Silverlight 4)?

Kind regards,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Zainab Vora
Top achievements
Rank 1
answered on 01 Sep 2010, 04:13 PM

Hello,

Thank you for quick response.

I am not modifying the ItemsSource of the gridview.

We are currently using silverlight 3 and silverlight 4 is not an option.

Is there any another way??

Thanks

 

0
Vlad
Telerik team
answered on 02 Sep 2010, 07:48 AM
Hello,

 Can you post the exact version of the grid?

Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vlad
Telerik team
answered on 02 Sep 2010, 08:05 AM
Hello,

 I've missed the version in your first post. Sorry! Do you have GridViewSelectColumn declared in your case? If this is the case you can download our latest official Silverlight 3 binaries - Q2 2010 SP1.

All the best,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Zainab Vora
Top achievements
Rank 1
Answers by
Zainab Vora
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Vlad
Telerik team
Share this question
or