3
Answers

unable to cast object of type system.string to type system.data.datarowview

Photo of Ankita Ankita

Ankita Ankita

13y
5.8k
1
I m getting this error. Firstly i have bind my list box with a cell in datagrid. when the row is selected the value of cell is is first assigned to a string variable and the that variable is then split near spaces stored in string array and that array is then assigned to list box.

After dat to assign multiple selected items to a label I used foreach loop as
 foreach(datarowview row in listbox.selecteditems)

near datarowview m getting unable to cast object of type system.string to type system.data.datarowview exception.


 

Answers (3)

0
Photo of Raaj Kumar
NA 1.6k 0 15y
Could you please post the stack trace of the exception?
0
Photo of Lalit M
NA 6.7k 48k 15y
Most probably there is some infinite loop getting executed in your code somewhere please check your loop may be endless.