DefaultValuesNeeded fails on Successive (repeated) Calls

11 posts, 1 answers
  1. John
    John avatar
    1 posts
    Member since:
    Mar 2009

    Posted 14 Apr 2010 Link to this post

    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?
  2. Answer
    Jack
    Admin
    Jack avatar
    2333 posts

    Posted 14 Apr 2010 Link to this post

    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.
  3. Lighthouse Developer
    Lighthouse Developer avatar
    34 posts
    Member since:
    Feb 2010

    Posted 03 Jun 2010 Link to this post

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

    Posted 08 Jun 2010 Link to this post

    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.
  5. John Reynolds
    John Reynolds avatar
    33 posts
    Member since:
    Sep 2008

    Posted 20 Apr 2011 Link to this post

    I'm seeing the same problem, with the latest release of Telerik Winforms.

    Can someone please confirm that this still hasn't been addressed?
  6. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 22 Apr 2011 Link to this post

    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
  7. Robert
    Robert avatar
    7 posts
    Member since:
    Jun 2012

    Posted 02 Jun 2013 Link to this post

    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?
  8. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 05 Jun 2013 Link to this post

    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?
  9. Robert
    Robert avatar
    7 posts
    Member since:
    Jun 2012

    Posted 09 Jun 2013 Link to this post

    That works. Thank you!
  10. Thomas
    Thomas avatar
    1 posts
    Member since:
    Jan 2013

    Posted 13 Jul 2013 Link to this post

    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
  11. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 17 Jul 2013 Link to this post

    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 >>
Back to Top