Yes, you may monitor this exception if your DropDownList WebControl is initialized programmatically, like
ddlDocumentState.DataValueField = "StateId";
ddlDocumentState.DataTextField = “StateName";
ddlDocumentState.DataSource = stateList;
ddlDocumentState.DataBind(); // <— here is exception thrown
If the data source doesn’t include an element with empty string as value, the above mentioned exception is thrown.
The problem is solved with setting SelectedValue of the DropDownList to null:
ddlDocumentState.DataValueField = "StateId";
ddlDocumentState.DataTextField = “StateName";
ddlDocumentState.SelectedValue = null; // <- added to solve
// the problem
ddlDocumentState.DataSource = stateList;
ddlDocumentState.DataBind(); // <— here is no more exception
Enjoy!
18 comments:
Excellent post. I learned a lot reading it. Thanks.
This will probably be the proper weblog in case you truly wants to look at this topic.
Say, you got a good article. Much thanks again. Wonderful.
Hi there. I discovered your website via Google even as looking for a related matter, your web site got here up. It appears great.
I want reading and I think this website got some really utilitarian stuff on it!
Quick question that's totally off topic. Do you know how to make your site mobile friendly?
@anonymous: check out microsoft guidlines for mobile web app using asp.net. keywords: skins, styles, browser dependend content, adapters.
mail me for more info
Appreciate your sharing this greatest doc.
Hey There. I found your weblog the usage of msn. This is a very well written article.
You have many managed to impress me by writing this thought-provoking informational article.
I am not sure where you are getting your information, but great topic.
Thanks for such a great post and the review, I am totally impressed!
I enjoyed this article. It was inspiring. Keep on posting!
Outstanding post, I conceive website owners should acquire a lot from this web site its really user pleasant. So much great information on here
Hiya. Very nice web site!!
I was just seeking for this information for a while.
Thanks For Your Information... Keep Posting
Cool!! Keep Posting
Post a Comment