Unable to cast object of type 'System.Int32' to type 'System.String' on all radButtons when radgrid is set to AllowMultiRowSelection="true"

2 posts, 0 answers
  1. Bryan
    Bryan avatar
    4 posts
    Member since:
    Nov 2015

    Posted 29 Jan 2017 Link to this post

    Okay, this took me a while to track down as the source of the problem, but I am out of options here and at my wits end. Every conversation I see even close to this is at best 2 years old, most 2010 or older, so I am desperate for help.


    Short version:

    -- radGrid on the page, GridClientSelectColumn set as first column, grud set to have AllowMultiRowSelection="true"

    -- after multiple items selected, radwindow used to allow user to edit selected item(s)

    If at any time after the window appears (whether it closes or not) any button that does a postback - partial or full - always throws a "Unable to cast object of type 'System.Int32' to type 'System.String'." error. I remove the "AllowMultiRowSelection="true"" (or otherwise set it to "false") everything works perfectly. If it is true, I always get the error, specifically when the grid refreshes. It does not fire any server-side code; the code dies well before it even gets to that point. The same happens is I set a radbutton to be AutoPostback="false" but then try to refresh the grid using client code; if I skip refreshing the grid completely, but I must refresh the grid each time to ensure I have the latest data on it.

  2. Bryan
    Bryan avatar
    4 posts
    Member since:
    Nov 2015

    Posted 30 Jan 2017 in reply to Bryan Link to this post

    Okay, so this core error was due to me passing in an integer to the "set_commandArgument" for a radbutton rather than an actual string (JS can be so picky!). However, I am noticing another quirk of the grid I would like to know about.

    As stated, I allow multi row selection, but if I use the selection, popup a window with the first selected item, then cancel the window and change the first selected item to a new one, that newly selected item is now at the bottom of the list rather than as the "new" first one.


    Let me try to explain:

    -- First time I select #3,4, and 5 rows

    -- I decided I don't want #3 but #1 instead, so I switch it

    -- Now the order for "grid.get_selectedItems()" is now #4, #5, and then #1

    Is there a way to tell it to swap the order around within the selected item list or at least refresh it so it goes through the list again?

    I get why it does this - its in the order it is selected; just wondering if there is a way to have it know the order on the page, and take the stuff "higher" in the row list before others? Or will I need to just iterate through the selected items from top down to ensure I am always in the same order?

Back to Top