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

DefaultValuesNeeded fails on Successive (repeated) Calls

10 Answers 173 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 14 Apr 2010, 06:51 AM
I have an Hierarchy GridView with two levels.  In the child gridview I want to Add a New Row, however I need to set some default values in the row, so I have used the DefaultValuesNeeded event to populate the new row with the required defaults.

This works well within one child view, however if I move to a different child view and try to Add a New Row, the DefaultValuesNeeded function fails with an error - NullReferenceException was unhandled.  This error is coming from the e.row.cells().value.

Here is the code that both works and fails:

Private Sub rgvVoucherServices_DefaultValuesNeeded(ByVal sender As Object, _  
        ByVal e As Telerik.WinControls.UI.GridViewRowEventArgs) _  
        Handles rgvVoucherServices.DefaultValuesNeeded  
        If TypeOf (rgvVoucherServices.CurrentRow) Is GridViewNewRowInfo Then 
            With e.Row  
                .Cells("ELS_ELVKey").Value = rgvVoucherServices.CurrentRow.ViewInfo.ParentRow.Cells("ELV_Key").Value  
                .Cells("ELS_LastUpdAction").Value = "I" 
                .Cells("ELS_LastUpdBy").Value = GlobalParameters("UserKey")  
                .Cells("ELS_LastUpdWhen").Value = Now  
            End With 
        End If 
    End Sub 

Is there a problem with the way that I have implemented this method?

10 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 14 Apr 2010, 02:09 PM
Hi John,

Thank you for reporting this issue.

I confirm that it appears in our latest release - Q1 2010 SP1 and I logged it in our bug tracking system. It will be addressed in one of our upcoming releases. I updated also your Telerik points.

Regards,
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.
0
Lighthouse Developer
Top achievements
Rank 1
answered on 03 Jun 2010, 02:08 PM
Hi Jack  and thank you  for your support

I want to ask if this bug is addressed in some beta etc version
or if a workaround exists,because I'm experiencing the same behavior
of DefaultValuesNeeded function in the Q1 2010 SP2 release.

Thank you very much again
0
Jack
Telerik team
answered on 08 Jun 2010, 03:41 PM
Hello,

This issue will be addressed in our upcoming Q2 2010 Beta due in the beginning of the next week. You can subscribe to our blogs RSS Feed which will inform you when the Beta is public.

All the best,

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.
0
John Reynolds
Top achievements
Rank 1
answered on 20 Apr 2011, 05:18 AM
I'm seeing the same problem, with the latest release of Telerik Winforms.

Can someone please confirm that this still hasn't been addressed?
0
Jack
Telerik team
answered on 22 Apr 2011, 11:39 AM
Hi John,

Thank you for contacting us. Just to note, our latest release is Q1 2011 SP1. Could you please confirm whether the issue appears in this release? If this is true, send us your application and we will try to locate the problem.

I am looking forward to your reply.
 
Kind regards,
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
0
Robert
Top achievements
Rank 1
answered on 03 Jun 2013, 03:20 AM
I'm experiencing the same problem in 2013.1.321.40. 

I'm using a master template with a child template. I need default values when adding a new row to the master template, but not the child template. The DefaultValuesNeeded event for the master template looks like this:

Private Sub GridViewPriceCurve_DefaultValuesNeeded(sender As System.Object, e As Telerik.WinControls.UI.GridViewRowEventArgs) Handles GridViewPriceCurve.DefaultValuesNeeded
    e.Row.Cells("ProductManager").Value = My.User.Name
    e.Row.Cells("IsCustom").Value = True
    e.Row.Cells("CreatedOn").Value = DateTime.Now
End Sub

This works fine for the master template but I get a null reference error when adding a new record to the child template. The child template doesn't have any of the columns in common with the master template. 

Any recommendations?
0
Stefan
Telerik team
answered on 05 Jun 2013, 08:50 AM
Hi Robert,

You can just check whether the Row template matches the desired template:
Private Sub radGridView1_DefaultValuesNeeded(sender As Object, e As GridViewRowEventArgs)
    If e.Row.ViewTemplate = radGridView1.MasterTemplate Then
          'set default values
    End If
End Sub

I hope this helps.
 
Regards,
Stefan
Telerik
RadChart for WinForms is obsolete. Now what?
0
Robert
Top achievements
Rank 1
answered on 09 Jun 2013, 04:44 PM
That works. Thank you!
0
Thomas
Top achievements
Rank 1
answered on 13 Jul 2013, 08:41 PM
When I try to add the below statement I get an error:
Operator '=' is not defined for types 'Telerik.WinControls.UI.GridViewTemplate' and 'Telerik.WinControls.UI.MasterGridViewTemplate'

Can you help me please.
If e.Row.ViewTemplate = RadGridView1.MasterTemplate Then
     'set default values
EndIf
0
Stefan
Telerik team
answered on 17 Jul 2013, 09:22 AM
Hello Thomas,

Here is what you can use instead: 
If e.Row.ViewTemplate.Equals(RadGridView1.MasterTemplate) Then
    'set default values
End If


Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Jack
Telerik team
Lighthouse Developer
Top achievements
Rank 1
John Reynolds
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Stefan
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or