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

Q3 2010 MasterTemplate.Refresh inside EndEdit causes exception

5 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 03 Dec 2010, 07:12 AM
Hi there,

I have a gridview which i just updated to the 2010 q3 and now I am getting errors every time i try to edit a cell.
It seems that every time I call gridview.MasterTemplate.Refresh() from within the end edit handler, I get an "Object reference not set to an instance of an object" error which originates from inside telerik code.

does anyone know why this is happening?

Thanks,
Matt

5 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 03 Dec 2010, 08:29 AM
Hello Mathew,

This happens because of the asynchronous nature of the Grid,
But can i ask why do you need this?

If you just want to refresh the current row, you can just use the following:
void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
    e.Row.InvalidateRow();
}

If you have a different purpose for doing this please let me know and i will offer a solution.

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

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Accepted
Jack
Telerik team
answered on 08 Dec 2010, 09:37 AM
Hi Matthew,

Yes, I confirm that there is an exception when calling GridViewTemplate.Refresh method when handling CellEndEdit event. When calling this method, it resets all UI elements in RadGridView and causes the grid to recreate them. I am not sure whether this is an issue. Please describe why you need to call this method when processing the CellEndEdit event. 

You can update the UI by calling the GridTableElement.Update method. Please consider the following code:
this.radGridView1.TableElement.Update(GridUINotifyAction.DataChanged);

I will be glad to help further and I am looking forward to your reply.

Regards,
Jack
the Telerik team
Get started with RadControls for WinForms with numerous videos and detailed documentation.
0
Matthew
Top achievements
Rank 1
answered on 09 Dec 2010, 11:43 PM
Thank you Jack,

That was stopped the error from ocurring.
However, now i'm finding that the selected row is lost after end edit.
I need to click in a cell to re-gain focus...
any ideas?

Matt
0
Matthew
Top achievements
Rank 1
answered on 09 Dec 2010, 11:46 PM
Nevermind, I've fixed it.

I'm now recording the selected row as the first step in endedit so i can use the GridNavigator to select it later

Thanks for your help with this!

Matt
0
Jack
Telerik team
answered on 16 Dec 2010, 05:39 PM
Hello Matthew,

I am glad to hear that you have found a solution for this issue. If you have any further questions, I will be glad to help.

Best wishes,
Jack
the Telerik team
Check out the Q1 2011 Roadmap for Telerik Controls for Windows Forms.
Tags
GridView
Asked by
Matthew
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Jack
Telerik team
Matthew
Top achievements
Rank 1
Share this question
or