I'm using Linq to bind data to a binddatasource which in trun feeds data to a radgridiview. It works fine when I first bind data to the radgridview. But if I changed the search criteria and thus the Linq statement, the radgrdiview throws the following exception.
Before I upgrade to 2009Q1 SP1, I need to
tblitemItemsBindingSource.DataSource = null; // throw exception if without this statement using 2008Q3
tblitemItemsBindingSource.DataSource = qItems.OrderBy(i => i.item_Code).ToList();
However, after upgraded to 2009Q1 SP1, the above line is no longer useful.
In my experience, 2009Q1 breaks more things more than it fixes. I'm very flustrated.
Edwin
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="Telerik.WinControls.GridView"
StackTrace:
at Telerik.WinControls.UI.BaseGridNavigator.get_CurrentGroup()
at Telerik.WinControls.UI.BaseGridNavigator.SelectRow(GridViewRowInfo row)
at Telerik.WinControls.UI.GridTableElement.UpdateCurrentPosition()
at Telerik.WinControls.UI.GridViewInfo.SetCurrentRow(GridViewRowInfo row, Boolean setPosition, Boolean shift, Boolean control, Boolean rightMouseButton)
at Telerik.WinControls.UI.GridViewTemplate.SetCurrentRow(GridViewRowInfo rowInfo)
at Telerik.WinControls.Data.DataAccessComponent.InitDataGrid()
at Telerik.WinControls.Data.DataAccessComponent.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.BindingSource.ResetBindings(Boolean metadataChanged)
at System.Windows.Forms.BindingSource.SetList(IList list, Boolean metaDataChanged, Boolean applySortAndFilter)
at System.Windows.Forms.BindingSource.ResetList()
at System.Windows.Forms.BindingSource.set_DataSource(Object value)
at PopularIT.MOSES.POS.UI.frmSearchItem.fillGrid(Boolean expandRows) in C:\Projects\MOSES.POS\MOSES.POS\UI\frmSearchItem.cs:line 85
at PopularIT.MOSES.POS.UI.frmSearchItem.txtItemName_KeyDown(Object sender, KeyEventArgs e) in C:\Projects\MOSES.POS\MOSES.POS\UI\frmSearchItem.cs:line 146
at System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)
at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at PopularIT.MOSES.POS.UI.frmSales.btnSearch_Click(Object sender, EventArgs e) in C:\Projects\MOSES.POS\MOSES.POS\UI\frmSales.cs:line 266
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at PopularIT.MOSES.POS.UI.frmMain.btnSales_Click(Object sender, EventArgs e) in C:\Projects\MOSES.POS\MOSES.POS\UI\frmMain.cs:line 121
at PopularIT.MOSES.POS.UI.frmMain.btnSalesNow_Click(Object sender, EventArgs e) in C:\Projects\MOSES.POS\MOSES.POS\UI\frmMain.cs:line 170
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at PopularIT.MOSES.POS.Program.Main() in C:\Projects\MOSES.POS\MOSES.POS\Program.cs:line 82
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
44 Answers, 1 is accepted
Sorry for the introduced inconvenience.
We logged the issue and it will be fixed for the next release.
Thank you for reporting the problem. Your Telerik points have been updated.
All the best,
Julian Benkov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I confirm this very disgracing bug, Is there a solution soon?
Thanks.
We are currently fixing some issues but we are not sure they are exactly the issues you are experiencing. Please send us a sample application so that we can make sure that the fixes address your issues correctly. Thank you very much in advance.
Edwin, can you please send us a sample application for the same reason. Thank you very much in advance.
Sincerely yours,
Julian Benkov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Please help me to resolve my problem.
I'm using GradGridView and BindingList for binding datasource. I added one column with type is RadGridViewMultiComboxColumn and the value of this column is sub object of data binding. Now, I have to add new row using "Click here to add new row". Everything is OK but if I double click into header of RadGridView for sorting and then I add new row again, the error Null Exception,Object reference not set to an instance of an object. I think the DataBoundItem of RadGridViewNewInfo is null.
Show me your solution if you know it. Thanks.
Please send us a simple example with your scenario to debug it locally. Thank you in advance.
Sincerely yours,
Julian Benkov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
By the way, I would like to ask you, could I set up the RadGridView with some rows can be edit and others rows can not? If yes, would you show me how? Thanks
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls.UI;
using System.Collections;
namespace TestTelerikSolution
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radGridView1.EnableHotTracking = false;
BindingList<TestListItem> list = new BindingList<TestListItem>();
list.Add(new TestListItem("Item 0", 0));
list.Add(new TestListItem("Item 1", 0));
list.Add(new TestListItem("Item 2", 1));
list.Add(new TestListItem("Item 3", 1));
radGridView1.GridElement.BeginUpdate();
radGridView1.MasterGridViewTemplate.AllowAddNewRow = true;
this.radGridView1.MasterGridViewTemplate.AutoGenerateColumns = false;
this.radGridView1.MasterGridViewTemplate.EnableSorting = true;
this.radGridView1.CurrentRowChanged += new CurrentRowChangedEventHandler(radGridView1_CurrentRowChanged);
radGridView1.MasterGridViewTemplate.Columns.Clear();
GridViewTextBoxColumn columnA = new GridViewTextBoxColumn("NullInt");
columnA.HeaderText = "Nullable Int Column";
columnA.Width = 200;
radGridView1.MasterGridViewTemplate.Columns.Add(columnA);
GridViewMultiComboBoxColumn columnB = new GridViewMultiComboBoxColumn("InnerObj.Id");
columnB.DisplayMember = "Name";
columnB.ValueMember = "Id";
BindingList<SimpleObj> newList = new BindingList<SimpleObj>();
newList.Add(new SimpleObj("Item 0", 0));
newList.Add(new SimpleObj("Item 1", 0));
newList.Add(new SimpleObj("Item 2", 1));
newList.Add(new SimpleObj("Item 3", 1));
columnB.DataSource = newList;
columnB.HeaderText = "New MultiCombox";
columnB.Width = 120;
radGridView1.MasterGridViewTemplate.Columns.Add(columnB);
radGridView1.GridElement.EndUpdate(false);
this.radGridView1.DataSource = list;
this.radGridView1.DataSource = list;
GridViewSummaryRowItem totals = new GridViewSummaryRowItem();
totals.Add(new GridViewSummaryItem("Str", "{0}", GridAggregateFunction.Count));
this.radGridView1.MasterGridViewTemplate.SummaryRowsTop.Add(totals);
}
class TestListItem : INotifyPropertyChanged
{
private string str;
private int? nullInt;
private SimpleObj innerObj;
public SimpleObj InnerObj
{
get { return innerObj; }
set
{
if (this.innerObj != value)
{
this.innerObj = value;
OnPropertyChanged("InnerObj");
}
}
}
public TestListItem()
{
str = "";
nullInt = 0;
innerObj = new SimpleObj();
}
public TestListItem(string a, int? b)
{
this.str = a;
this.nullInt = b;
}
public string Str
{
get { return this.str; }
set
{
if (this.str != value)
{
this.str = value;
OnPropertyChanged("Str");
}
}
}
public int? NullInt
{
get { return this.nullInt; }
set
{
if (this.nullInt != value)
{
this.nullInt = value;
OnPropertyChanged("NullInt");
}
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
}
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (PropertyChanged != null)
PropertyChanged(this, e);
}
#endregion
}
class SimpleObj : INotifyPropertyChanged
{
private int? id;
private string name;
public SimpleObj()
{
id = 0;
name = "";
}
public SimpleObj(string _name, int? _id)
{
this.name = _name;
this.id = _id;
}
public string Name
{
get { return name; }
set
{
if (this.name != value)
{
this.name = value;
OnPropertyChanged("Name");
}
}
}
public int? Id
{
get { return id; }
set
{
if (this.id != value)
{
this.id = value;
OnPropertyChanged("Id");
}
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
}
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (PropertyChanged != null)
PropertyChanged(this, e);
}
#endregion
}
}
}
I tested you code snippet with our latest version Q1 2009 SP1 (v2009.1.9.414), but I was not able to reproduce any issues in the described scenario. I noticed that you are subscribing to the CurrentRowChanged event, but you have not included the code for the event handler, so I commended out this subscription.
Here is what I did using the code snippet provided:
1. Click twice on 'Click here to add a new row' in the Nullable Int Column cell and enter a value, for example "5".
2. Press enter so that the new row gets added.
3. Click on the Nullable Int Column header cell to sort by this column (or click twice to get descending sort).
4. Perform step 1 and then step 2.
The result is two rows added correctly and no exception thrown. Could you please tell me if I am missing something in this case?
As to the row editing, you can use the CellBeginEdit if you want to set a certain row to readonly. Please refer to the code snippet below:
void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) |
{ |
if (e.RowIndex == 2) |
{ |
e.Cancel = true; |
} |
} |
Best wishes,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
i cannot give you a sample now, but the bug is:
null reference exception ("La référence d'objet n'est pas définie à une instance d'un objet") in french,
And the stack trace is:
à Telerik.WinControls.UI.BaseGridNavigator.get_CurrentGroup()
à Telerik.WinControls.UI.BaseGridNavigator.SelectRow(GridViewRowInfo row)
à Telerik.WinControls.UI.GridTableElement.UpdateCurrentPosition()
à Telerik.WinControls.UI.GridViewInfo.SetCurrentRow(GridViewRowInfo row, Boolean setPosition, Boolean shift, Boolean control, Boolean rightMouseButton)
à Telerik.WinControls.UI.GridViewTemplate.SetCurrentRow(GridViewRowInfo rowInfo)
à Telerik.WinControls.Data.DataAccessComponent.InitDataGrid()
à Telerik.WinControls.Data.DataAccessComponent.currencyManager_ListChanged(Object sender, ListChangedEventArgs e)
à System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
à System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
à System.Windows.Forms.BindingSource.OnListChanged(ListChangedEventArgs e)
à System.Windows.Forms.BindingSource.InnerList_ListChanged(Object sender, ListChangedEventArgs e)
à System.Data.DataView.OnListChanged(ListChangedEventArgs e)
à System.Data.DataView.IndexListChanged(Object sender, ListChangedEventArgs e)
à System.Data.DataView.IndexListChangedInternal(ListChangedEventArgs e)
à System.Data.DataViewListener.IndexListChanged(ListChangedEventArgs e)
à System.Data.Index.<OnListChanged>b__2(DataViewListener listener, ListChangedEventArgs args, Boolean arg2, Boolean arg3)
à System.Data.Listeners`1.Notify[T1,T2,T3](T1 arg1, T2 arg2, T3 arg3, Action`4 action)
à System.Data.Index.OnListChanged(ListChangedEventArgs e)
à System.Data.Index.FireResetEvent()
à System.Data.DataTable.RestoreIndexEvents(Boolean forceReset)
à System.Data.DataTable.EndLoadData()
à System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
à System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
à System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
à System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
à System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
à INTERFACEOPTIFLUX.InterfaceOptifluxDataSetTableAdapters.REPARTTableAdapter.FillOnlyNonEnvoyee(REPARTDataTable dataTable) dans C:\PROJECTS\INTERFACEOPTIFLUX\INTERFACEOPTIFLUX\INTERFACEOPTIFLUX\InterfaceOptifluxDataSet.Designer.cs:ligne 5469
à INTERFACEOPTIFLUX.FrmPrincipale.LoadRepart() dans C:\PROJECTS\INTERFACEOPTIFLUX\INTERFACEOPTIFLUX\INTERFACEOPTIFLUX\Form_Principale.cs:ligne 191
à INTERFACEOPTIFLUX.FrmPrincipale.MenuiItemRefresh_Click(Object sender, EventArgs e) dans C:\PROJECTS\INTERFACEOPTIFLUX\INTERFACEOPTIFLUX\INTERFACEOPTIFLUX\Form_Principale.cs:ligne 133
à Telerik.WinControls.RadItem.OnClick(EventArgs e)
à Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
à Telerik.WinControls.RadItem.DoClick(EventArgs e)
à Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
à Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
à Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
à Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
à Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
à Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
à Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
à System.Windows.Forms.Control.WndProc(Message& m)
à System.Windows.Forms.ScrollableControl.WndProc(Message& m)
à Telerik.WinControls.RadControl.WndProc(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.Run(Form mainForm)
à INTERFACEOPTIFLUX.Program.Main() dans C:\PROJECTS\INTERFACEOPTIFLUX\INTERFACEOPTIFLUX\INTERFACEOPTIFLUX\Program.cs:ligne 18
à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()
The problem appears when i rebind my gridview like this :
i EDIT my second level of the hierarch grid expanded, and i save it into my database doing :
this.Validate();
MyBindingSource.EndEdit();
MyTableAdapter.Update(myDatatable);
MySecondLevelBindingSource.EndEdit();
MySecondLevelTableAdapter.Update(MySecondLevelDatatable);
After i want to refresh my grid doing:
this.MyTableAdapter.Fill(this.myProgramDataSet.myDatatable);
And the Exception is throwed during this last operation....
The probleme seems to be linked with get_CurrentGroup() function.
thank you for your help....
Nbody can help me?
i had tried the internal build, same problem,
so i open a support ticket....Grrrr
Unfortunately, we are not able to reproduce the issue with the code and the additional information provided. Hence we are not able to give you a suitable workaround if such is possible and address the issue further.
Therefore, we will be glad to receive a sample project from you in the support ticket that you opened. This will allow us to investigate the issue further.
Thank you for your cooperation.
Kind regards,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank you for your help.
I can reproduce my problem with your sample!
Open your sample.
Expand any row.
Edit a value in the second level.
Hit return or click anywhere in the grid for validate your edit.
Clik "refill Suppliers Button"
Thank you for a quick response!
Thanks again!
I was able to reproduce the issue and it will be addressed in one of our next versions. For the time being, please call BeginUpdate()/EndUpdate() methods when you rebind:
this.radGridView1.GridElement.BeginUpdate(); |
this.suppliersTableAdapter.Fill(this.nwindDataSet.Suppliers); |
this.radGridView1.GridElement.EndUpdate(); |
If you have additional questions, feel free to contact us.
Sincerely yours,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Firstable, thank you very much to take care of my problem.
But the problem is not completely solved by your solution, try this, after have add the Beginupdate() and Endupdate() methods to the fill buttons:
Open your sample.
Expand any row.
Edit a value in the second level.
Hit return or click anywhere in the grid for validate your edit.
Clik "refill Suppliers Button": first time, now, after your solution implemented, it's OK !
Clik again "refill Suppliers Button": second time => :-/ Same Bug....
I really need a solution because i have to delivery my project to my customer, and i cannot let this kind of bug, so please give another reliable solution, or please give me as "internal build" a fixed dll assembly.
Thank you for a quick response!
Thanks again!
Please find the answer to your question in the your support ticket regarding the same issue.
Best wishes,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Setting RadGrid.DataSource = null will result in unhandled exception. We will have to wait for Telerik to fix in the next release. (Q2, I suppose)
Workaround is dont use RadGrid.DataSource = null. Call RadGrid.Columns.Clear().
Reason for unhandled exception pertaining to setting datasource is null because there might be custom settings like ConditionalFormat, Filters which is not getting cleared.
I had a similar issue to this but stack trace showed exception down in get_IsHierachical() for the grid.
My grid had detail tables.
Turned out that if i changed the datasource (= null or = new data) where the data did not have a matching relation to generate the detail table, the exception was thrown.
So i've just updated my grid definition (done in code) to clear the relations anytime the data source changed.
uiGrid.GridElement.BeginUpdate(); |
...snip... |
uiGrid.Relations.Clear(); |
...snip... |
uiGrid.GridElement.EndUpdate(true); |
Thanks to Pradeep for making me think about other things which might need to be cleared in this case.
Sylvain Langlade, your issue with RadGridView is addressed in Q2 2009. Please download this release and give it a spin.
Richard van Diggelen and Pradeep, please test your projects with Q2 2009, since the issues that you have in your scenarios may be addressed there. If you continue having exceptions, please open new support tickets, send us sample projects and describe the steps which we should follow in our tests with your projects. This will allow us to help you further.
Best wishes,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
"radGridView.DataSource = null"; // As I have seen this will always result in exception. I believe there is still work needs to be
// done by telerik on this.
Resolution:
// Clear the Conditinal Formats
// Clear the Filters
// and finally dont forget to clear the columns.
radGridView.Columns.Clear();
Try this...
// **************************************//
Scenarios may happen where you will need to clear conditional formatting and Filters by looping through them...
// *********************************//
Eddie, I tested this scenario with our latest release - Q3 2009 and I was not able to reproduce it. I recommend that you install this version and try it. It contains many improvements and bug fixes. Could you please also confirm that the issue is addressed in Q3? If not, please open a support ticket and send us your project so we can investigate the case further. Thank you in advance for your cooperation.
Sincerely yours,
Jack
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.
we´ve just updated from RadControls f. WinForms Q1 2009 to Q3 2009 and we now get that exception when setting datasource:
GridView.DataSource = DataTable
Stacktrace:
bei Telerik.WinControls.UI.TextPart.Measure(SizeF availableSize)
bei Telerik.WinControls.UI.LayoutManagerPart.Measure(SizeF availableSize)
bei Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize)
bei Telerik.WinControls.UI.GridDataCellElement.MeasureOverride(SizeF availableSize)
bei Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
bei Telerik.WinControls.RadElement.Measure(SizeF availableSize)
bei Telerik.WinControls.RadElement.MeasureOverride(SizeF availableSize)
bei Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize)
bei Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
bei Telerik.WinControls.RadElement.Measure(SizeF availableSize)
bei Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
bei Telerik.WinControls.UI.GridTableBodyElement.ArrangeOverride(SizeF finalSize)
bei Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
bei Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
bei Telerik.WinControls.UI.GridTableElement.ArrangeOverride(SizeF finalSize)
bei Telerik.WinControls.RadElement.ArrangeCore(RectangleF finalRect)
bei Telerik.WinControls.RadElement.Arrange(RectangleF finalRect)
bei Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
bei Telerik.WinControls.RadElement.UpdateLayout()
bei Telerik.WinControls.UI.GridTableElement.EnsureRowVisible(GridViewRowInfo rowInfo)
bei Telerik.WinControls.UI.GridViewRowInfo.EnsureVisible()
bei Telerik.WinControls.UI.BaseGridNavigator.SetCurrentRow(Boolean shift, Boolean ctrl)
bei Telerik.WinControls.UI.BaseGridNavigator.SelectRow(GridViewRowInfo row)
bei Telerik.WinControls.UI.GridTableElement.UpdateCurrentPosition()
bei Telerik.WinControls.UI.GridViewInfo.SetCurrentRow(GridViewRowInfo row, Boolean setPosition, Boolean shift, Boolean control, Boolean rightMouseButton)
bei Telerik.WinControls.UI.GridViewTemplate.SetCurrentRow(GridViewRowInfo rowInfo)
bei Telerik.WinControls.Data.DataAccessComponent.InitDataGrid()
bei Telerik.WinControls.Data.DataAccessComponent.Bind(Object dataSource, String dataMember)
bei Telerik.WinControls.Data.DataAccessComponent.set_DataSource(Object value)
I´m very sorry, but that is absolutely frustrating:
Everytime we try to JUST INSTALL AN UPDATE of RadControls (we´re using WinForms and ASP.NET Controls) we have to change a lot of our programcode like binding datasources to different controls (gridviews, comboboxes, ...) which works different with every RadControls Release!!!
Daniel
I understand your concerns. However, I am not able to solve the issue by using this stack trace. Please send us your project so we can test and locate the issue. I will try find the best option. I am looking forward to your reply.
Best wishes,
Jack
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.
since last thursday I´m working to get your update work for us and - I´m sorry - I just gave up for now. We don´t have enough time / money to "do your job". The problem also is: We had to work around the bugs in Q1 and now we get new bugs with Q2 / Q3 and our workarounds have some sideeffects too...
As I remeber it could have something to do with some attached eventhandlers?! (Or better: It did not crash if some of these handlers were not attached.) - But I´m not sure.
GridView.CommandCellClick += GridView_CommandCellClick;
GridView.CellBeginEdit += GridView_CellBeginEdit;
GridView.CellEndEdit += GridView_CellEndEdit;
GridView.CellFormatting += GridView_CellFormatting;
I´m not able to send a sample project yet - may be later.
Greetings,
Daniel
Yes, We understand your situation and will be glad to help in resolving this issue. However, we didn't managed to reproduce it. Please send us your application and we will fix it. I am looking forward to your reply.
Greetings,
Jack
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.
after updating to Q3 SP1 We had the same problem, but I found out, what happened:
In our gridview there is an invisible GridViewDateTimeColumn and a visible GridViewMaskBoxColumn. Last one is used for entering dates via keyboard like this: Date to enter is 2009-12-15 you just enter 15122009 (German format).
After entering some text into the GridViewMaskBoxColumn in CellEndEdit the text is parsed for a valid DateTime. If it is a valid DateTime the DateTime is written into the GridViewDateTimeColumn else DBNull.Value is written into that column (GridViewCellInfo). When CellFormatting is raised, the value of the GridViewDateTimeColumn is "copied back" to the GridViewMaskBoxColumn. That means: If the GridViewDateTimeColumn contains a DateTime, DateTime.ToShortDateString() is written to the Text-property of the GridViewMaskBoxColumn´s cell. If the GridViewDateTimeColumn contains DBNull.Value, null is written to the Text-property of the GridViewMaskBoxColumn´s cell:
object deliveryDate = currentRow.Cells["DateTimeColumn"].Value;
if (deliveryDate is DateTime)
{
// currentCell is the GridViewMaskBoxColumn´s cell
currentcell.Text = ((
DateTime)deliveryDate).ToShortDateString();
}
else
{
currentcell.Text = null
;
}
And that´s just the problem: If I don´t set the text to null, but to String.Empty everything works fine.
Greetings,
Daniel
I am glad to hear that you have found a solution to this issue and I confirm that it exists in our latest release. I logged the issue in our bug tracking system and it will be addressed in the next release. I updated also your Telerik points.
All the best,Jack
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.
I think, it's veryyyyyyyy difficult to upgrade when using Telerik Winform Controls. Their approach to new releases needs some big re-thinking.
May be they need someone with a different thinking in their strategy team.
It's very frustrating.
I am not sure which issue are you targeting. If you need assistance, please specify the issue and we will be glad to help. We decided to concentrate our efforts on bug fixes for Q1 2010 and did not introduce new features. This allowed us to refactor several important parts of RadGridView. You can find more information about our upcoming release in this blog article.
Sincerely yours,
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.
I'm using RadControls Q1 2010 SP1.
I use a RadGridView "matgrid" bound to a List<MM_Materials>.
MM_Materials is a poco. It has a member MM_MaterialVariants which is a List<MM_MaterialVariants>.
MM_MaterialVariants is also a poco .
I'm trying to set up a hierarchical grid. As soon as I try to expand a row with the '+'-Button, I get the obvously "well-known" null reference exception.
//Creating the childTemplate |
GridViewTemplate template = new GridViewTemplate(matgrid); |
template.AutoGenerateColumns = false; |
template.AllowDragToGroup = false; |
template.AllowEditRow = false; |
template.Columns.Add(new GridViewDataColumn("Material", "Material")); |
template.Columns.Add(new GridViewDataColumn("MaterialVariant", "MaterialVariant")); |
template.Columns.Add(new GridViewDataColumn("MaterialVariantStatus", "MaterialVariantStatus")); |
matgrid.MasterGridViewTemplate.ChildGridViewTemplates.Add(template); |
//Creating the relation |
GridViewRelation relation = new GridViewRelation(matgrid.MasterGridViewTemplate); |
relation.ChildTemplate = template; |
relation.RelationName = "MaterialsMaterialVariants"; |
relation.ParentColumnNames.Add("MaterialID"); |
relation.ChildColumnNames.Add("Material"); |
matgrid.Relations.Add(relation); |
//Setting the Data Sources |
matgrid.DataSource = materials; |
matgrid.MasterGridViewTemplate.ChildGridViewTemplates[0].DataSource = materials; |
matgrid.MasterGridViewTemplate.ChildGridViewTemplates[0].DataMember = "MM_MaterialVariants"; |
I tried to write a new Class MyGridView, inheriting RadGridView. In this class I added an MouseDown-Event:
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) |
{ |
try |
{ |
base.OnMouseDown(e); |
} |
catch |
{ |
//Here the null reference exception occurs. Do nothing. |
} |
} |
If I do it that way, I can continue working but have to click every '+'-Button twice to expand the child grid.
Any (quick) help would be appreciated.
Thank you.
Stefan
Currently, we do not support object-relational hierarchy and this scenario can't be implemented in RadGridView. However, this is one of the major features that we will present in our upcoming version - Q2 2010.
We want to know more about your scenario. Please give us more details and we will consider the case when developing our new feature. Thank you for your time.
If you have any other questions, feel free to write back.
Jack
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.
I am having the same issue (as the original thread). This has something to do with the System.Collections.IList.get_Item(Int32 index).
I created a simple project using the example in the WinForms Q2 2010 help documentation (http://www.telerik.com/help/winforms/grid_binding-to-generic-lists.html) - binding to a simple generic collection of list. Ran the project and tried to add a new item...and kapowie (that's techie for WTF)...
Help?!?
Seems to be a .Net framework issue. I was using version 4. Changed the target framework to 3.5 and all seems ok now.
Paul
I am glad to hear that your issue is solved now. If you have further questions or issues, do not hesitate to contact us back.
Regards,Julian Benkov
the Telerik team
Try Clearing the Columns, filters, Conditional format and Grouping before loading GridView1.DataSource. I hope this will resolve your issue.
Not a good work around though but works for me :)
Prad
We still build our components upon .NET Framework v2.0. This allows those who rely on this framework to use our components without compatibility issues. Nevertheless, we want to be compatible will all new versions of the .Net framework and I want to thank you for this information. We will do tests and will investigate this case in detail.
Versile, I am sorry to hear this. We always try to keep the breaking changes at minimum and we make changes only when they are necessary to improve our products. We are always ready to help you with the transition process and if there is an issue that you can not solve, please contact us and send us your application. We will make all changes for you.
Pradeep, thank you for your solution. Please, describe what is the issue that forces you to use this work around. We will try to locate and address it.
Regards,
the Telerik team
radGridView1.datasource = null; (bing... this is where it hits the exception).
** Note load these settings using layout structure (.LoadLayout). Do not create them @ Design time.
You may not get this error for the first load of the application. Maybe repeated runs should get you this error.
Let me know if this helps...
Prad
Thank you for these details. We know about several issues related to the save/load layout functionality in RadGridView and currently we are working to finxing them. They will be addressed in our upcoming service pack in the beginning of September. However, I was not able to reproduce this particular issue. Please, could you send me a sample application that reproduces it (in a new support ticket)? This will ensure that the issue will be addressed in our service pack. Thank you in advance.
I am looking forward to your project.
Jack
the Telerik team
Hello
After upgrading from 2015.1.331.40 to 2017.3.912 (trial) i ran into a similar issue with RadGridView. In RunWorkerCompleted routine I assign a list of instances of a class having named public properties as the DataSource.of RadGridView. This causes exception System.NullReferenceException. Unfortunately it is very difficult to produce a code demonstrating the error because data is retrieved from an SQL server. I also removed all list entries except one and double checked that no named property returns NULL. However, the assignment of the DataSource member causes the following exception:
System.NullReferenceException occurred
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=<Cannot evaluate the exception source>
StackTrace:
at Telerik.WinControls.VisualElement.GetScaledFont(Single scale)
at Telerik.WinControls.UI.LightVisualElement.CreateTextParams()
at Telerik.WinControls.UI.GridCellElement.CreateTextParams()
at Telerik.WinControls.UI.TextPart.Measure(SizeF availableSize)
at Telerik.WinControls.UI.LayoutManagerPart.Measure(SizeF availableSize)
at Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.UI.GridCellElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.UI.GridDataCellElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.UI.VirtualizedStackContainer`1.MeasureElementCore(RadElement element, SizeF availableSize)
at Telerik.WinControls.UI.VirtualizedColumnContainer.MeasureElement(IVirtualizedElement`1 element)
at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureElements()
at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.UI.GridVirtualizedRowElement.MeasureElements(SizeF availableSize, SizeF clientSize, Padding borderThickness)
at Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.UI.GridRowElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.UI.ScrollableRowsContainerElement.MeasureElementCore(RadElement element, SizeF availableSize)
at Telerik.WinControls.UI.VirtualizedStackContainer`1.MeasureElement(IVirtualizedElement`1 element)
at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureElements()
at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.UI.ScrollableRowsContainerElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.UI.RowsContainerElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.UI.ScrollViewElement`1.MeasureViewElement(SizeF availableSize)
at Telerik.WinControls.UI.ScrollViewElement`1.MeasureView(SizeF availableSize)
at Telerik.WinControls.UI.ScrollViewElement`1.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.UI.GridTableElement.MeasureOverride(SizeF availableSize)
at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
at Telerik.WinControls.UI.GridVisibilityHelper.EnsureRowVisible(GridViewRowInfo rowInfo)
at Telerik.WinControls.UI.GridTableElement.EnsureRowVisible(GridViewRowInfo rowInfo)
at Telerik.WinControls.UI.GridTableElement.EnsureCellVisible(GridViewRowInfo rowInfo, GridViewColumn column)
at Telerik.WinControls.UI.GridTableElement.UpdateViewCore(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridTableElement.UpdateView(Object sender, DataViewChangedEventArgs args)
at Telerik.WinControls.UI.GridTableElement.ProcessTemplateEvent(GridViewEvent eventData)
at Telerik.WinControls.UI.GridTableElement.Telerik.WinControls.UI.IGridViewEventListener.ProcessEvent(GridViewEvent eventData)
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
at Telerik.WinControls.UI.GridViewSynchronizationService.RaiseCurrentChanged(GridViewTemplate template, GridViewRowInfo row, GridViewColumn column, Boolean user)
at Telerik.WinControls.UI.GridViewTemplate.CollectionView_CurrentChanged(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at Telerik.WinControls.Data.RadCollectionView`1.OnCurrentChanged(EventArgs args)
at Telerik.WinControls.Data.RadCollectionView`1.SetCurrentPositionCore(Int32 newPosition, Boolean forceNotify, CurrentChangeReason reason)
at Telerik.WinControls.Data.RadDataView`1.SyncCurrent(TDataItem item)
at Telerik.WinControls.Data.RadDataView`1.RebuildData(Boolean notify)
at Telerik.WinControls.Data.RadDataView`1.RefreshOverride()
at Telerik.WinControls.Data.RadDataView`1.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
at Telerik.WinControls.Data.RadCollectionView`1.source_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at Telerik.WinControls.Data.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at Telerik.WinControls.Data.RadListSource`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.WinControls.Data.RadListSource`1.EndUpdate(Boolean notifyUpdates)
at Telerik.WinControls.Data.RadListSource`1.Initialize()
at Telerik.WinControls.Data.RadListSource`1.Bind(Object dataSource, String dataMember)
at Telerik.WinControls.Data.RadListSource`1.set_DataSource(Object value)
at Telerik.WinControls.UI.GridViewTemplate.set_DataSource(Object value)
at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)
at iCCAnalyzerClient.AgentMultimediaData.BackgroundWorker1_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e) in C:\versionhallinta\ICCAnalyzerClient - VVO\iCCAnalyzerClient\Asiakaspalvelija_Historia\AgentMultimediaData.vb:line 370
at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
at System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object arg)
How can I enable debug output to see, which named property exactly caused the exception in Telerik ?
This appears to be connected with the DPI support. However, without a way to reproduce it, I cannot suggest a solution. Could you please open a new thread and add your code there (no need to adding data). This will allow us to test this locally and see if we can reproduce it.
What you can try is disabling the DPI scaling on a global level:
public
RadForm1()
{
InitializeComponent();
RadControl.EnableDpiScaling =
false
;
}
I hope this will be useful.
Regards,
Dimitar
Progress Telerik