[Last Call] Learn how to a build a cloud-first strategyRegister Now


Items.Insert Conflict with Value Field

Posted on 2009-02-20
Medium Priority
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

jmwheeler earned 1000 total points
ID: 23696668
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

ID: 23711841

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 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