Yesterday, as I was plugging away on an ASP WebForms application to add some new features, I encountered an error I had not yet seen.
“SelectedValue which is invalid because it does not exist in the list of items”
Although Googling turned up a lot of results, I could not really find anything that fit the bill as a solution. I did find a few threads on StackOverflow, though usually these discussions were followed up with additional people asking how the original asker resolved the issue.
For me, it turns out that I was calling the block of code that performed the list population and databind multiple times. Populating and calling DataBind on this DropDownList multiple times, resulted in the above error. In the end (after much forehead beating), the solution was an easy one – checking items before attempting to populate and bind to ensure the list was not already initialized.
if (yourDropDownList.Items.Count() == 0) //only populate and bind if not already done…
//populate and bind
That is it – just checking to ensure the items for the drop down list have not already been populated. Of course, you really should have your application structured so that this logic is only hit once…. This said, if a complete refactor/rewrite is not in the cards for your application at this time, you can just perform this simple check to work around the exception.
Hope this helps someone!
I am hoping that in posting this, someone is able to save a little time and frustration.
On my Ubuntu 10.10 machine with CouchDB 1.0.1 installed, I began experiencing the following error every time I attempted to ‘couchapp push’ my couchapp changes:
[CRITICAL] Expecting object: line 2 column 3 (char 4)
After a bit of noggin scratching (and perhaps a little mumbled cussing), I started thinking about the fact I had not upgraded my couchapp install since long before I last upgraded CouchDb.
Running the following cleared up all error and put me back in the happy land of ‘couchapp push’:
“easy_install -U couchapp”
Yup… Just a version issue… Hope this saves someone a few gray hairs…
So, I came to post a quick quip about how much I liked Inception today and realized how little I use my blog anymore. Not that I have ever been a competitive blogger or anything of the sort, but it would seem that I have withered and dried up – at least so far as these posts are concerned (and likely reflect).
None the less, that is not the case (me withering and drying) as I have just been really, really (really) busy reading and trying to get myself up to speed as a professional programmer… Something that I am enjoying emensely (even though it sometimes feels as if I will never ever (ever) know enough to take a breath again – GOOD THING IT’S SUPA FUN!).
Speaking of something I have recently enjoyed (and my reason for sitting down 15 mins ago to begin writing this) – watching Inception (I’ll wait while you see what it is if you don’t know)… Oddly, there is more related between the first part of this post (developing as a developer) and the fun provided by Inception – conceptually at least… I have to say, I was genuinely entertained at the layering and constant thought provoking representations of recursion and Big-O concepts… I won’t go into it much more than that, but if you find this stuff interesting, you will likely enjoy aspects of the movie that may perhaps will be overlooked by “other watchers” of Inception. Funny thing is, I get back home, head over to browse hacker news and quickly come to the realization that I was not alone in my CS-centric thoughts about the film – http://news.ycombinator.com/item?id=1526104
Aside from the mentally stimulating representation of CS-Theory-related concepts, there is PLENTY of eye-candy by way of perty explosions and mind-bending (and physically defying) scenery to keep you entertained – even if the exotic applications of recursion aren’t your cup of tea.
I’d give Inception an ‘A’.
Updated: April 6, 2010 9:50pm CST – Correction (Below)
When reading/working through the 2nd edition of Apress’ ‘Practical Django Projects’, I hit a hang. A big hang. And like most big hangs, it was actually a very small (technically speaking) bump in the road. The problem is that when looking to “how to” books such as ‘Practical Django Projects’, it is easy to fall back to the book’s printed text as the absolute code bible of what is and what is not correct in this world of code. Unfortunatly, as was the case with me, this can lead to wasted hours and (after-the-fact) embarrassing frustration.
As I have seen this mentioned on forums around the interwebs while researching this myself, I figured I would document the solution here. I am happy to say that I do not have to cite reference here as I figured this out myself and have submitted an errata report to the publisher. What I am not as happy to admit is the fact that when you see what the problem here is, you will not be impressed (and will likely kick yourself as clearly you are reading this for help – and don’t really need it)… So on to the meat…
PG.24-25 – the tiny_mce.js referral to load TinyMCE in your Flatpages… You set it up, just as the book instructs and BAM – nothing… No TinyMCE and a Firebug inspection of the page shows that the tiny_mce.js cannot be found (404).. Again, the error is actually quite simple, of course making it all the more simple to overlook when error correcting…
Hope this helps someone…
I saw a posting about the Google Code University on Hacker News this morning. A quick inspection of the site shows a nice set of tutorials on Python, C++, Java and Go.
I personally worked through Google’s Python Class last night and found it to be easy to follow and relatively comprehensive on the basics – this one alone is enough for me to at least recommend a visit.
I really hope that there is more to come to the Code University in the near future!