Filtering: Type 'Pair' to type 'String'

5 posts, 0 answers
  1. Chanan Zass
    Chanan Zass avatar
    50 posts
    Member since:
    Aug 2012

    Posted 29 Aug 2011 Link to this post

    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.
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 01 Sep 2011 Link to this post

    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 >>

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. kfrancis
    kfrancis avatar
    69 posts
    Member since:
    Dec 2008

    Posted 12 Sep 2011 Link to this post

    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
  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 12 Sep 2011 Link to this post

    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
  6. Chanan Zass
    Chanan Zass avatar
    50 posts
    Member since:
    Aug 2012

    Posted 12 Sep 2011 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017