Required Field Validator for drop down list reading from Database

Posted on 2009-04-20
Last Modified: 2013-11-07
Hi im trying to use Visual studios required field validator for a drop down list. I want the first selection to be "please select" and if this is selected then the required field validaor will be displayed. t works fine if I just manually added values and had the first value equal to blank.

I am reading the values in the drop down however From a SQL Server database table. It contains 2 columns: one for the ID and one for the value. I've tried adding in a blank row
In both the load and unload and it still doesn't add the row for me.

i.e. ddlNonProductiveCategoryID.Items.Insert(0, "asdas") and i've also tried adding it using the wizzard for editing items but any item I add doesn't get displayed only the values in the database.

I know once I can get the row 'please select' added and set it's selectedvalue to blank then I can set it's selected value to blank

Question by:GlobexCorp
    LVL 1

    Accepted Solution

    Hi GlobexCorp,

    Normaly I use C# but try something like this:

            Me.ddlNonProductiveCategoryID.DataSource = New DataProvider().Datasource
            Me.ddlNonProductiveCategoryID.DataTextField = "id"
            Me.ddlNonProductiveCategoryID.DataValueField = "value"
            Me.ddlNonProductiveCategoryID.Items.Add(New ListItem("asdas", "0"))


    LVL 83

    Expert Comment

    Usually you can not add items to list manually if it is databound. What code are you using?
    LVL 2

    Author Closing Comment

    cheers for that just used Insert instead of add to put it at thre top of the list

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    This video discusses moving either the default database or any database to a new volume.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now