Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Required Field Validator for drop down list reading from Database

Posted on 2009-04-20
3
Medium Priority
?
617 Views
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

Thanks
0
Comment
Question by:GlobexCorp
3 Comments
 
LVL 1

Accepted Solution

by:
hendrik_johns earned 2000 total points
ID: 24184347
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.DataBind
        Me.ddlNonProductiveCategoryID.Items.Add(New ListItem("asdas", "0"))

Cheers,

Hendrik
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24184877
Usually you can not add items to list manually if it is databound. What code are you using?
0
 
LVL 2

Author Closing Comment

by:GlobexCorp
ID: 31572217
cheers for that just used Insert instead of add to put it at thre top of the list
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

571 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