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

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

1 Answer 335 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bryan
Top achievements
Rank 1
Bryan asked on 30 Jan 2017, 02:43 AM

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.

1 Answer, 1 is accepted

Sort by
0
Bryan
Top achievements
Rank 1
answered on 30 Jan 2017, 05:47 PM

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?

Tags
Grid
Asked by
Bryan
Top achievements
Rank 1
Answers by
Bryan
Top achievements
Rank 1
Share this question
or