Operator '<>' is not defined for types 'GridViewTemplate' and 'RadGridView'.

1 Answer 219 Views
GridView
Nandan
Top achievements
Rank 1
Iron
Iron
Iron
Nandan asked on 30 May 2022, 01:46 PM

Hi 

I am developing winform project in vb.net sometime i checked answers in forum written in c#  but same sample does not work in vb.net

Now i am facing problem radgridview cellvaluechanged in master detail scenario

C#

  private void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e)
        {
            if (e.Column.OwnerTemplate != radGridView1.MasterTemplate && e.ColumnIndex == 3)
            {
                EvaluateTotal((GridViewRowInfo)e.Row.Parent);
            }
        }

vb.net

  Private Sub rdgvPendingRpt_CellValueChanged(sender As Object, e As GridViewCellEventArgs) Handles rdgvPendingRpt.CellValueChanged
        If e.ColumnIndex = 3 AndAlso e.Column.OwnerTemplate <> rdgvPendingRpt Then
            EvaluateTotal(CType(e.Row.Parent, GridViewRowInfo))
        End If
    End Sub

Error  Operator '<>' is not defined for types 'GridViewTemplate' and 'RadGridView'.

it giving me error in above line. I am attaching screenshot for same.  

Kindly do the needful

Regards

Nandan Navale

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 May 2022, 01:50 PM

Hello, Nandan,

Please have in mind that the OwnerTemplate property is type of GridViewTemplate and it can be compared to an instance of the same type, not another type, e.g. RadGridView instance in your case. Every RadGridView offers the MasterTemplate property. Feel free to use it when comparing teh templates.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Nandan
Top achievements
Rank 1
Iron
Iron
Iron
commented on 30 May 2022, 04:55 PM | edited

Hello Dess

Thank you.

I resolved the issue with your help. Now i write same code which is provided in above code which is written is C# not working in my case. I am sharing code with you. Please check 

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        AddHandler rdgvPendingRpt.CellValueChanged, AddressOf Me.rdgvPendingRpt_CellValueChanged
    End Sub

    Private Sub frmTest_Load(sender As Object, e As EventArgs) Handles Me.Load
        With rdgvPendingRpt
            .AutoGenerateColumns = False
            .EnableFiltering = True
            .MasterTemplate.ShowHeaderCellButtons = True
            .MasterTemplate.ShowFilteringRow = False
            .CurrentRow = Nothing
        End With

        rdgvPendingRpt.DataSource = FetchReceiptData()

        Dim template As GridViewTemplate = New GridViewTemplate()

        template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill
        template.DataSource = FetchUsedData()

        Me.rdgvPendingRpt.MasterTemplate.Templates.Add(template)

        Dim relation As GridViewRelation = New GridViewRelation(rdgvPendingRpt.MasterTemplate, template)

        relation.ChildTemplate = template
        relation.RelationName = "ReceiptIssue"
        relation.ParentColumnNames.Add("colReceiptDetailsId")
        relation.ChildColumnNames.Add("ReceiptDetailsId")
        rdgvPendingRpt.Relations.Add(relation)

        'rdgvPendingRpt.Columns.Add("colUsedWt")
        'For Each item In rdgvPendingRpt.ChildRows
        '    EvaluateTotal(item)
        'Next

        BuildHierarchy()
    End Sub

    Private Function FetchReceiptData() As DataTable
        Dim dtData As DataTable = New DataTable()

        Try
            Dim parameters = New List(Of SqlParameter)()
            parameters.Clear()

            With parameters
                parameters.Add(dbManager.CreateParameter("@ActionType", "GetReceiptData", DbType.String))
            End With

            dtData = dbManager.GetDataTable("SP_PendingVoucher_Select", CommandType.StoredProcedure, parameters.ToArray())

        Catch ex As Exception
            MessageBox.Show("Error:- " & ex.Message)
        End Try

        Return dtData
    End Function

    Private Function FetchUsedData() As DataTable
        Dim dtData As DataTable = New DataTable()

        Try
            Dim parameters = New List(Of SqlParameter)()
            parameters.Clear()

            With parameters
                parameters.Add(dbManager.CreateParameter("@ActionType", "GetUsedData", DbType.String))
            End With

            dtData = dbManager.GetDataTable("SP_PendingVoucher_Select", CommandType.StoredProcedure, parameters.ToArray())

        Catch ex As Exception
            MessageBox.Show("Error:- " & ex.Message)
        End Try

        Return dtData
    End Function

    Private Sub EvaluateTotal(ByVal parent As GridViewRowInfo)
        parent.Cells(8).Value = rdgvPendingRpt.Evaluate("Sum(GrossWt)", parent.ChildRows)
    End Sub

    Private Sub BuildHierarchy()
        For Each item In rdgvPendingRpt.ChildRows
            EvaluateTotal(item)
        Next
    End Sub

    Private Sub rdgvPendingRpt_CellValueChanged(sender As Object, e As GridViewCellEventArgs) Handles rdgvPendingRpt.CellValueChanged
        If e.ColumnIndex = 8 AndAlso e.Column.OwnerTemplate IsNot Me.rdgvPendingRpt.MasterTemplate Then
            EvaluateTotal(CType(e.Row.Parent, GridViewRowInfo))
        End If
    End Sub

CellValueChanged event not fired

attaching screen shot also . 

Regards

Nandan Navale

Dess | Tech Support Engineer, Principal
Telerik team
commented on 31 May 2022, 01:46 PM

Hi, Nandan,

RadGrdiView supports calculated columns which are identified by an expression. The only condition necessary to make a regular column behave like a calculated column is to set an expression to it. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/gridview/columns/calculated-columns-(column-expressions

This approach is suitable for expression columns which use columns from the same hierarchy level. However, if you need to display in the parent level the sum of the child rows, it is necessary to do it programmatically by iterating the ChildRows collection for each parent row and evaluating the sum. Then, the obtained result should be assigned to the respective parent cell's value. 

Note that most of the forum threads are reviewed by Telerik representatives and sometimes we address the questions asked by our customers in the forums as well. However, a post in the forum doesn't guarantee you a response from the Telerik support team. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread. In the support ticket you can also provide a runnable sample project demonstrating the undesired behavior that you are facing. Thus, our support staff will gladly assist you.

I hope this information helps.
Nandan
Top achievements
Rank 1
Iron
Iron
Iron
commented on 31 May 2022, 01:52 PM

Hi

one more question on which grid event i should use for showing message that [details not found]

Attaching screenshot for the same

 

Regards

Nandan

 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 01 Jun 2022, 12:39 PM

Hi, Nandan,

To be honest, I am not sure whether the illustrated MessageBox comes from the RadGridView control. I have also checked the RadGridLocalizationProvider as it contains all localizable strings used in RadGridView and such a message is not available there.

RadGridView offers the DataError event for handling any undesired error messages that might occur during the program execution related to the grid. However, without replicating the precise case locally, it wouldn't be easy to give you direct guidance or any tips on this. That is why I would kindly ask you to submit a support ticket from your Telerik account and provide a sample runnable project demonstrating the undesired behavior you are facing. Thus, we would be able to make an adequate analysis of the precise case and provide further assistance. 

Tags
GridView
Asked by
Nandan
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or