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

BUG PROBLEM

14 Answers 425 Views
GridView
This is a migrated thread and some comments may be shown as answers.
yarik
Top achievements
Rank 1
yarik asked on 21 Aug 2007, 04:19 PM
hi
i set a data source (data table ) to the grid with the line

DataGrid.DataSource = dt;

then i save some staff in my DB and then i wanted to bound  different data table to the same grid using the same command line
DataGrid.DataSource = saveddt;

but i get a null reference exception

Object reference not set to an instance of an object.

  at Telerik.WinControls.UI.GridTableBodyElement.editor_Validated(Object sender, EventArgs e)\r\n   at Telerik.WinControls.UI.RadCheckBoxEditor.OnValidated(EventArgs args)\r\n   at Telerik.WinControls.UI.RadCheckBoxEditor.SaveValue()\r\n   at Telerik.WinControls.UI.GridTableBodyElement.ResetActiveEditor(Boolean restoreOriginalValue)\r\n   at Telerik.WinControls.UI.GridTableBodyElement.Update(Boolean dataSourceChanged)\r\n   at Telerik.WinControls.UI.GridTableElement.Update(Boolean dataSourceChanged)\r\n   at Telerik.WinControls.UI.GridViewInfo.UpdateView(Boolean dataSourceChanged)\r\n   at Telerik.WinControls.UI.GridViewInfo.UpdateView()\r\n   at Telerik.WinControls.UI.GridViewTemplate.Rebind()\r\n   at Telerik.WinControls.UI.RadGridView.RefreshColumnsAndRows()\r\n   at Telerik.WinControls.UI.GridViewData.InitDataOnly()\r\n   at Telerik.WinControls.UI.GridViewData.InitView()\r\n   at Telerik.WinControls.UI.GridViewData.SetDataConnection(Object dataSource, String dataMember)\r\n   at Telerik.WinControls.UI.RadGridView.DoDataBinding()\r\n   at Telerik.WinControls.UI.RadGridView.CallDoDataBinding()\r\n   at Telerik.WinControls.UI.GridViewTemplate.set_DataSource(Object value)\r\n   at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)\r\n  

14 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 22 Aug 2007, 12:35 PM
Hello Yarik,

we can't reproduce the reported problem with the latest SP2 release. RadGridView works fine when changing the DataSource in run-time. Please, open a support ticket and send us a example with your scenario so that we can review it locally. 
 

Sincerely yours,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Sasa Milovic
Top achievements
Rank 1
answered on 31 Aug 2007, 12:27 PM
I get the same if i have a selected row in the grid.
0
Julian Benkov
Telerik team
answered on 31 Aug 2007, 01:17 PM
Hello Sasa,

We will ask you to open a support ticket and send us a example with your scenario so that we can review it locally. We did not get Yarik's project, so we are still in the dark what is going on. I would like to confirm that we can't reproduce the reported problem with the latest SP2 release and that RadGridView works fine when changing the DataSource in run-time. 
 
Thank you for your understanding.


All the best,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Sasa Milovic
Top achievements
Rank 1
answered on 31 Aug 2007, 01:39 PM
Hi

I did add detail about this bug in a support ticket I have open.

Let me be more specific for other poor users out there who may be suffering from the same problem.

If I have a column which is a "checkbox column", and I click a checkbox (which also selects the row), and then I bind a new datasource to the grid, I get the exception. This is using Sp2.

(also, I can't get the format code block toolstrip item to work on this forum. I click it and get an empty radwindow object?)

Here is a really simple form u can try this with. (just create a form with a rad grid and button and hook up events)

Imports Telerik.WinControls.ui

Public Class Form1


    Dim colFileName As GridViewTextBoxColumn
    Dim colUpgradeName As GridViewBooleanColumn

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        RadGridView1.DataSource = GetCollection()

    End Sub


    Private Sub AddColumns()

        colFileName = New GridViewTextBoxColumn
        colFileName.DataField = "FileName"
        colFileName.HeaderText = "File Name"
        colFileName.ReadOnly = True
        RadGridView1.MasterGridViewTemplate.Columns.Add(colFileName)

        colUpgradeName = New GridViewBooleanColumn
        colUpgradeName.HeaderText = "New / Updated"
        colUpgradeName.DataField = "Upgrade"
        RadGridView1.MasterGridViewTemplate.Columns.Add(colUpgradeName)

    End Sub

    Private Function GetCollection() As List(Of ReleaseFileInfo)
        Dim list As New List(Of ReleaseFileInfo)

        Dim file1 As New ReleaseFileInfo
        file1.FileName = "aaa"
        file1.Upgrade = False
        list.Add(file1)

        Dim file2 As New ReleaseFileInfo
        file2.FileName = "aaa"
        file2.Upgrade = False
        list.Add(file2)

        Return list

    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddColumns()
    End Sub

End Class

    Public Class ReleaseFileInfo


        Private _fileName As String
        Public Property FileName() As String
            Get
                Return _fileName
            End Get
            Set(ByVal value As String)
                _fileName = value
            End Set
        End Property


        Private _upgrade As Boolean
        Public Property Upgrade() As Boolean
            Get
                Return _upgrade
            End Get
            Set(ByVal value As Boolean)
                _upgrade = value
            End Set
        End Property


    End Class


0
Sasa Milovic
Top achievements
Rank 1
answered on 31 Aug 2007, 01:48 PM
Haha - Its that boolean column. It's baaaaad.

In the example, if i set it to "Readonly", the rebind works.

Even funnier than that, if I click on the checkbox, I doesn't toggle the value, but if I click in the same column, next to the checkbox, it DOES toggle the value. on a READONLY column.

This is not the first time I've had trouble with that column type. Will this finally be fixed in the next release, because if it isn't then I am going to drop this Grid component once and for all, and try regain my sanity.
0
Jack
Telerik team
answered on 31 Aug 2007, 03:13 PM
Hello Sasa,

We are deeply sorry for this inconvenience. All issues related to boolean column are fixed now and they will be publicly available in our next release (we are expecting the beta no later than Tuesday next week). This beta will contain fixes for the issues you mentioned. We will appreciate it if you share your experience with the new version.
 

All the best,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
AT
Top achievements
Rank 1
answered on 13 Aug 2009, 01:13 PM
I just downloaded the lastest build posted (2009.2.804) and I am still experiencing the "Object reference not set to an instance of an object." issue when trying to change the datasource of the grid.

I have a boolean data column in my grid. I'm not even trying to edit that, I'm editing a text box, then switching datasources and then I get the exception.

Update:
My grid has a mix of read only, editable controls, and a boolean column. If I edit the text box, or the boolean column, then click on a read only column, then switch the datasource, then switch the datasource again. That produces the exception. The datasource of the grid becomes nothing and Any attempt to change the datasource after that also fails.

Stack trace of exception:
   at Telerik.WinControls.UI.RadGridView.ValidateRowChange(GridViewRowInfo row)   
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.Bind(Object dataSource, String dataMember)   
at Telerik.WinControls.Data.DataAccessComponent.set_DataSource(Object value)   
at Telerik.WinControls.UI.RadGridView.set_DataSource(Object value)   
at JMInterface.frmWeeklySchedule.SetSchType() in E:\WorkingFolder\JMv6\Interface\frmWeeklySchedule.vb:line 305

0
AT
Top achievements
Rank 1
answered on 13 Aug 2009, 02:16 PM
I just submitted a bug report on this with a sample project and some screen shots.

ID: 234893
0
Jack
Telerik team
answered on 14 Aug 2009, 07:04 AM
Hello mmassey,

You can find the answer to your question in the support ticket (ID: 234893). Should you have any questions, we will be glad to help.

All the best,
Jack
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.
0
Rachel
Top achievements
Rank 2
answered on 03 Sep 2009, 09:55 PM
Hello,
I am also sometimes seeing the Telerik.WinControls.UI.RadGridView.ValidateRowChange(GridViewRowInfo row) exception when changing the datasource, although I have been unable to track it to a specific column clicking scenario.  But it does appear that after a time spent editing cells in one grid, then changing the datasource, the execption occasionally occurs.  

I'm curious as to what the solution was in this case?

Thank you,
Rachel
0
Jack
Telerik team
answered on 04 Sep 2009, 11:55 AM
Hi Rachel,

There is indeed an issue with ValidateRowChange method that we will address in our upcoming release. This issue appears when navigating through read-only cells and then changing the data source of RadGridView. You can work around this issue by changing the default grid behavior. You should inherit from BaseGridBehavior and override its OnMouseDownLeft event. Here is a sample:

this.radGridView1.GridBehavior = new MyGridBehavior(); 
 
public class MyGridBehavior : BaseGridBehavior 
       protected override bool OnMouseDownLeft(MouseEventArgs e) 
       { 
              GridDataCellElement cell = this.GridControl.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement; 
              if (cell != null 
                     && !cell.Equals(this.GridControl.CurrentCell) 
                     && cell.RowInfo.Equals(this.GridControl.CurrentRow) 
                     && cell.ColumnInfo.ReadOnly) 
              { 
                     this.GridControl.EndEdit(); 
              } 
              return base.OnMouseDownLeft(e); 
       } 

To solve the issue in case of a checkbox column, you can handle the ValueChanged event:

private void radGridView1_ValueChanged(object sender, System.EventArgs e) 
    if ((sender) is RadCheckBoxEditor) 
    { 
        RadGridView1.EndEdit(); 
    } 

If the issue appears when the focus is changed between two grids, you can add the following code inside the LostFocus event handler:

void radGridView1_LostFocus(object sender, EventArgs e) 
    this.radGridView1.EndEdit(); 

If this does not help, we will need to review your application to see what else is going on.

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.
0
Rachel
Top achievements
Rank 2
answered on 11 Sep 2009, 07:36 PM
Hello Jack,
Thank you for helping us on this issue.

I added these workarounds and it did seem to stop the error, however the EndEdit being called on the grid's LostFocus even makes editing dates using the DateTimePicker in the grid non-functional, so we cannot use it.  We have also noticed the checkbox EndEdit prevents the ValueChanged event from triggering on the checkboxeditor.  Is there perhaps a more global solution for this that doesn't involve calling EndEdit in these places?  Or can we expect a fix in a release sometime soon?

Thanks again,
Rachel


0
Mateo
Top achievements
Rank 1
answered on 11 Sep 2009, 08:52 PM

Hello we are experiencing the same problem when rebinding the datasource.

We are not using any checkbox in that grid, only textbox, combobox and datetime.

At one point it get bugged and throws exception all the time...

Can we expect a release soon to fix this problem.

thanks

mateo

0
Jack
Telerik team
answered on 15 Sep 2009, 07:14 AM
Hi Rachel,

The first one is easy. You should just check whether RadGridView contains the focus:

void radGridView1_LostFocus(object sender, EventArgs e) 
    if (!this.radGridView1.ContainsFocus) 
    { 
        this.radGridView1.EndEdit(); 
    } 

I didn’t understand the second issue. You can place your code just before EndEdit call.

Unfortunately, there is no global solution for this issue. We plan to address it in our upcoming release in November.

Mateo, please send us your project. We will try to locate the issue. 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.
Tags
GridView
Asked by
yarik
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Sasa Milovic
Top achievements
Rank 1
Jack
Telerik team
AT
Top achievements
Rank 1
Rachel
Top achievements
Rank 2
Mateo
Top achievements
Rank 1
Share this question
or