25/05/2013

How to deal with error" invalid argument = value of 0 is not valid for selectedindex" ?

In the process of developing a code for my one of form I come on cross with this error, which wasted my lost of precious time and energy. I  did lots of experiments to sort out this error but not succeeded, even I googled it but  all in vain . 
Then my sixth sense told me that have I added any data in database to show it through combobox, when I checked, I found there is no data in that column which is attached with combobox, so I added some data in that particular column and my error got vanished and my code start working perfectly. So if you got error like " invalid argument = value of 0 is not valid for selectedindex"  first thing you should do is to check your database for data and  if there is no data in that particular column with is linked with your combobox  because this error only generate when combobox is not getting any data from database and you are setting value for selectedindex for combobox control.

No comments:

Post a Comment

What & How