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

Filtering: Type 'Pair' to type 'String'

4 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chanan Zass
Top achievements
Rank 1
Chanan Zass asked on 29 Aug 2011, 10:44 PM
Greetings,

We have a RadGrid with filtering enabled; the page is ajaxified and includes a RadWindowManager as well.
We've been using filtering for a while now with no problem. However, here the filtering fails with an error message:
Error: Sys.WebForms.PageRequestManagerServerErrorException: Conversion from type 'Pair' to type 'String' is not valid.

Anyone has encountered this kind of error message?
The only difference from other RadGrids where filtering works without a problem is the RadWindowManagers. Is there a conflict we're not aware of?

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 01 Sep 2011, 09:38 AM
Hello Chanan Zass,

Could you share the whole page with us? Because I am unable to replicate the issue with the provided information only.

Kind regards,
Vasil
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Kori
Top achievements
Rank 2
answered on 12 Sep 2011, 07:12 PM
Chanan,

CommandArgument is an object, you're likely assuming it's usually a string. When filtering, we find that it's not what we're usually expecting and we get the type "Pair" (no idea where it comes from).

A little error checking, and you should be able to bypass the issue.

-- Kori
0
Jayesh Goyani
Top achievements
Rank 2
answered on 12 Sep 2011, 07:38 PM
Hello,

((Pair)e.CommandArgument).First == "NoFilter" // type of filter like.. contains,equal to,greater then
((Pair)e.CommandArgument).Second == "OrderDate"  // Column Unique name

for more info please check below link.
http://www.telerik.com/help/aspnet/grid/grdfilteringfordatetimecolumnwithdataformatstring.html

let me know if any concern.

Thanks,
Jayesh Goyani
0
Chanan Zass
Top achievements
Rank 1
answered on 12 Sep 2011, 09:16 PM
Thanks, guys.

The reported error was due to our RadGrid1_ItemCommand, where we coded a procedure to generate PDF documents.
We ignored the possible filter command.
So when we wrote
Dim myCommandArgument As String = e.CommandArgument

We got the conversion error (from Pair to String).
This is our current code snippet:
Protected Sub RadGrid1_ItemCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.ItemCommand
        Dim myCommandArgument As String
        Dim strError As String = ""
        If e.CommandName = "CreatePdf" Then
            myCommandArgument = e.CommandArgument
 
            If myCommandArgument.ToString.Length > 0 Then
                strError = CreatePDF(myCommandArgument)
                If strError.Length > 0 Then
                    RadGrid1.Controls.Add(New LiteralControl("<font color='red'>Could not create the PDF file.<br />The server returned the following error: <br />" & strError & "</font>"))
                    Exit Sub
                End If
            Else
                RadGrid1.Controls.Add(New LiteralControl("<font color='red'>Could not create PDF document as no document identifiers have been provided." & "</font>"))
            End If
        End If
    End Sub
Tags
Grid
Asked by
Chanan Zass
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Kori
Top achievements
Rank 2
Jayesh Goyani
Top achievements
Rank 2
Chanan Zass
Top achievements
Rank 1
Share this question
or