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

NullReferenceException when tabbing out of the last cell on a row.

3 Answers 27 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Svein Thomas
Top achievements
Rank 1
Svein Thomas asked on 29 Nov 2010, 11:57 AM
Hi guys,

I have a grid binded to a Linq datasource. Binding is done by hand/code when populating data.
Some of the data needs a editable grid, and some dont. I therefor switch between two datasources and switch between making the grid readonly and writable.

When its in writable mode, i'm able to write data into the cells and a new row is added automatically if move to another row (with the arrowbuttons) or click outside the row, but if i tab out of the last cell in the row i get an NullReferenceException ("Object reference not set to an instance of an object")?. I use the latest version of the grid (2010.3.10.1109).

Any idea?

Regards
Svein Thomas

3 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 29 Nov 2010, 12:14 PM
Hello,

I haven't been able to replicate this issue at the moment. Please could you try this really basic exmaple. I understand it is not using LINQ, but I think it's best to start testing with the most basic sample possible and then we can add to that to try and replicate to get to the route of your problem. This is just a RadGridView on a form.

Look forward to hearing back from you.
Richard

Are you able to post a sample that will replicate it?

Public Class Form1
  
  
  
    Private Sub Form1_Load(ByVal sender As System.Object,
                           ByVal e As System.EventArgs) Handles MyBase.Load
  
  
        Me.RadGridView1.Columns.Add(New GridViewTextBoxColumn("A"))
        Me.RadGridView1.Columns.Add(New GridViewCheckBoxColumn("B"))
        Me.RadGridView1.Columns.Add(New GridViewTextBoxColumn("C"))
  
        Me.RadGridView1.AllowAddNewRow = False
  
        Dim rowInfo As GridViewRowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A1"
        rowInfo.Cells(1).Value = False
        rowInfo.Cells(2).Value = "Richard"
        rowInfo = Me.RadGridView1.Rows.AddNew()
        rowInfo.Cells(0).Value = "A2"
        rowInfo.Cells(1).Value = True
        rowInfo.Cells(2).Value = "Peter"
  
  
    End Sub
  
End Class
0
Emanuel Varga
Top achievements
Rank 1
answered on 29 Nov 2010, 09:08 PM
Hello Sven,

Are you saying that you are receiving a null reference while tabbing to the end of the NewRow? Are you sure this is not related to the way objects are created in your data source? You could try handling the UserAddingRow event and cancelling that event and adding the object to the collection from there.

If this is not the case, please provide some more details on the current scenario.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
Jack
Telerik team
answered on 02 Dec 2010, 02:23 PM
Hello Svein,

Thank you for contacting us.

We were not able to reproduce this issue. Like Emanuel and Richard suggested, it will help us if you could send a sample application which reproduces the issue. This will allow us to understand the case and find a proper solution. Please note that you have to open a new support ticket in order to be able to attach files. Thank you in advance.

I am looking forward to your project.
 
Best wishes,
Jack
the Telerik team
Get started with RadControls for WinForms with numerous videos and detailed documentation.
Tags
GridView
Asked by
Svein Thomas
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Emanuel Varga
Top achievements
Rank 1
Jack
Telerik team
Share this question
or