Items.Insert Conflict with Value Field

Posted on 2009-02-20
Last Modified: 2012-06-21
I have a conflict with the following piece of code-
 ddClient.Items.Insert(0, "Select A Client")

Initially, when I display the asp:dropdownlist, I use 0 (zero) for a value,
but I also have a value of 0 (zero) as a valid value for ClientID.
So, In my sp behind the scenes, when I check for the value 0 and I want to display 'Unknown'
after getting the results from my sp; there is a conflict.

Is there any way around this?
I tried setting it to -1 but that didnt work.
i.e.  ddClient.Items.Insert(0, "Select A Client")

"Select A Client" didnt show up at all....
Question by:jtrapat1
    LVL 11

    Accepted Solution

    Have you tried inserting the item specifying both the text and the value?

    ddClient.Items.Insert(0, new ListItem("Select a Client", ""))

    Then you would check to see if ddClient.SelectedValue = "" to determine if something was selected.

    Author Comment


    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video discusses moving either the default database or any database to a new volume.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 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

    19 Experts available now in Live!

    Get 1:1 Help Now