"Object reference not set to an instance of an object." when radgridview is bound to new data

43 posts, 0 answers
  1. Edwin
    Edwin avatar
    27 posts
    Member since:
    Jun 2012

    Posted 15 Apr 2009 Link to this post

    Hi
    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:
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 17 Apr 2009 Link to this post

    Hello Edwin,

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Sylvain Langlade
    Sylvain Langlade avatar
    11 posts
    Member since:
    Jun 2008

    Posted 07 May 2009 Link to this post

    Hi,

    I confirm this very disgracing bug, Is there a solution soon?

    Thanks.
  5. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 08 May 2009 Link to this post

    Hi Sylvain Langlade,

    We are working on it and a fix will be available in our next internal build planned for May the 18th. You will be informed as soon as the internal build is uploaded.

    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.
  6. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 11 May 2009 Link to this post

    Hello Sylvain Langlade,

    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.
  7. Quynh
    Quynh avatar
    2 posts
    Member since:
    May 2009

    Posted 19 May 2009 Link to this post

    Hello Telerick Master,

    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.
  8. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 20 May 2009 Link to this post

    Hello Quynh,

    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.
  9. Quynh
    Quynh avatar
    2 posts
    Member since:
    May 2009

    Posted 20 May 2009 Link to this post

    Thanks Telerik Master for your support and this is my simple example for my issue

    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

        }




        }
    }
  10. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 22 May 2009 Link to this post

    Hello Quynh,

    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.
  11. Sylvain Langlade
    Sylvain Langlade avatar
    11 posts
    Member since:
    Jun 2008

    Posted 25 May 2009 Link to this post

    Hi Telerik,

    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....






  12. Sylvain Langlade
    Sylvain Langlade avatar
    11 posts
    Member since:
    Jun 2008

    Posted 26 May 2009 Link to this post

    Help ??

    Nbody can help me?


    i had tried the internal build, same problem,

    so i open a support ticket....Grrrr
  13. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 27 May 2009 Link to this post

    Hi Sylvain Langlade,

    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.
  14. Sylvain Langlade
    Sylvain Langlade avatar
    11 posts
    Member since:
    Jun 2008

    Posted 28 May 2009 Link to this post

    Hi,

    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!
  15. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 28 May 2009 Link to this post

    Hi Sylvain Langlade,

    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.
  16. Sylvain Langlade
    Sylvain Langlade avatar
    11 posts
    Member since:
    Jun 2008

    Posted 28 May 2009 Link to this post

    Hello Nikolay ,

    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!
  17. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 28 May 2009 Link to this post

    Hello Sylvain Langlade,

    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.
  18. Prad
    Prad avatar
    35 posts
    Member since:
    Apr 2008

    Posted 02 Jun 2009 Link to this post

    Hi Sylvain,

      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.
  19. Richard van Diggelen
    Richard van Diggelen avatar
    8 posts
    Member since:
    Jul 2012

    Posted 01 Jul 2009 Link to this post

    Hi,

    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.
  20. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 08 Jul 2009 Link to this post

    Hello guys,

    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.
  21. Eddie Jenkins
    Eddie Jenkins avatar
    4 posts
    Member since:
    Nov 2008

    Posted 17 Nov 2009 Link to this post

    I believe I am having the same issue with regards to changing the datasource on a GridViewTemplate.  My problem is as such:

    I have a RadGridView with children templates (for this example we'll say there is only 1 for simplicity's sake). when i try to change the datasource, to either null or a different view, I get the Object reference not set to an instance of an object exception.

    Here is some psuedo code:

    RadGridview grid = myGrid;

    GridViewTemplate template = myGrid.MasterGridViewTemplate.ChildGridViewTemplates[0];

    // Error happens here:
    template.DataSource = null;

    //And if i comment the line above out, the same error, happens here:
    template.DataSource = myDataSet.Tables[1].DefaultView;

    I am using the 2009.2.9.729 DLLs.

    Any help would be appreciated.
  22. Prad
    Prad avatar
    35 posts
    Member since:
    Apr 2008

    Posted 17 Nov 2009 Link to this post

    My suggestion is to not call for

    "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();
  23. Eddie Jenkins
    Eddie Jenkins avatar
    4 posts
    Member since:
    Nov 2008

    Posted 17 Nov 2009 Link to this post

    Using the previous code, I have added this to my code:

    [code]
    template.EnableFiltering = false;
    template.EnableGrouping = false;
    template.EnableSorting = false;
    template.Columns.Clear();

    template.DataSource = myDataSet.Tables[1].DefaultView;
    [/code]

    I am guessing that in order to clear the conditional formatting and filters i set the enableXXX to false.
    I cannot see how to clear any conditional formatting.  Is there something I am missing?

    BTW, the above code results in the same error.

  24. Prad
    Prad avatar
    35 posts
    Member since:
    Apr 2008

    Posted 17 Nov 2009 Link to this post

    Try this... 

    RadGridview grid = myGrid;

    GridViewTemplate template = myGrid.MasterGridViewTemplate.ChildGridViewTemplates[0];

    template.Columns.Clear();
    template.DataSource = myDataSet.Tables[1].DefaultView;

    // **************************************//
    Scenarios may happen where you will need to clear conditional formatting and Filters by looping through them...
    // *********************************//

  25. Eddie Jenkins
    Eddie Jenkins avatar
    4 posts
    Member since:
    Nov 2008

    Posted 17 Nov 2009 Link to this post

    I have added the recommended code into my source and am still having the exception being thrown.  I have also tried looping through the columns and removing any formatting still to no avail.

    foreach (GridViewDataColumn column in template.Columns)
        column.FormatString = "";

    I am at a loss.  Thank you for the quick responses and great suggestions.  Hopefully this will be "resolved in the next release", as it seems all problems are.
  26. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 18 Nov 2009 Link to this post

    Pradeep, thank you for your suggestion.

    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.
  27. DGPunkt
    DGPunkt avatar
    20 posts
    Member since:
    Apr 2007

    Posted 19 Nov 2009 Link to this post

    Hello,

    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
  28. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 23 Nov 2009 Link to this post

    Hi DGPunkt,

    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.
  29. DGPunkt
    DGPunkt avatar
    20 posts
    Member since:
    Apr 2007

    Posted 23 Nov 2009 Link to this post

    Hi Jack,

    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

  30. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 24 Nov 2009 Link to this post

    Hi DGPunkt,

    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.
  31. DGPunkt
    DGPunkt avatar
    20 posts
    Member since:
    Apr 2007

    Posted 08 Dec 2009 Link to this post

    Hi Jack,

    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

Back to Top
UI for WinForms is Visual Studio 2017 Ready