This chapter will discuss this last type of control, known as custom controls, and a subset of them called user controls.

But for most of your “one time” loads, this works great.

So lets attach a basic Required Field Validator control to this Drop Down List since we want to make sure a value has been specified: This validator displays an * next to the control itself and the error message is getting piped over to a Validator Summary control (not shown).

The problem with this configuration is that by default, the Selected Index is set to 0 for the Drop Down List when it is databound.

If you were to drop a simple Required Field Validator and target the drop down list, it would evaluate as Valid every time you submitted, since it treats –1 as a legitimate value.

Stop that vicios frustration cycle and become a better person overall. Download fully tested and 100% working Visual Studio solution with the source code used in this article for FREE - just enter your name and email in the form below, and I’ll send you the download link right away!

Not only you’ll get the complete code for this article, you’ll also get access to all the source code for all the articles on the site forever, as well as the access to my mailing list, which receives handy time-saving tips on . So the basic Drop Down List looks like this: One quick note, which I had discovered along the way.The Append Data Bound Items property will take any statically created List Items you have in the control and bind them to the Drop Down List before your databound elements are added.Both of these fields are required – this way we can test rendering of selected dropdown list value on the postback.The following bits and pieces are needed: As said above, this code runs twice – first when user loads the ‘Sign Up’ page in the browser and the form is displayed, and second time when user submits the form. The nature of browser forms is such that only selected values are posted back, and if you want to display the form after a postback (in case there’s a validation error in one of the form’s controls, for example), you need to populate all the supplementary data again, otherwise controls such as Drop Down Lists will be just rendered empty.I’ll show you how to display that list on a form, how to get user’s selection in the controller, check that user has selected something and render the list back to the user with the value selected. Hold that thought for now and have a look at the Microsoft’s own documentation for the ?