Solved

Dropdownlist control in ASP.NET

Posted on 2004-09-29
2
168 Views
Last Modified: 2010-04-06
Hi all experts.
I have a web form page written in VB.NET and there is a dropdownlist control bound to a datareader on it.
       
        Dim myCommand As OdbcCommand
        Dim myConnection As New OdbcConnection(myConnString)

        myCommand = New OdbcCommand
        myCommand.CommandText = "Select name, email From tblRep Order By name"
        myCommand.Connection = myConnection
        myConnection.Open()
        Me.ddlRep.DataSource = myCommand.ExecuteReader()
        Me.ddlRep.DataTextField = "name"
        Me.ddlRep.DataValueField = "email"
        Me.ddlRep.DataBind()
        myConnection.Close()

Everything looks fine. All data is correctly bound to the dropdownlist. The problem is the page with dropdownlist is designed to display inquiry information summary and administrator opens this page, views the inquiry and finally assigns it to an appropriate personal to handle. But the dropdownlist always displays the first item in the control, so even though the administrator reviewed an inquiry and didn't assign it to any personnel at the moment, the page saves the first person in the control as an assigned rep. Is there a way to bind a control with the first item blank or something like that to prevent unwanted record from being saved.
Thanks
0
Comment
Question by:soweyoung
2 Comments
 
LVL 20

Accepted Solution

by:
ihenry earned 125 total points
ID: 12192922
Try this,

        Me.ddlRep.DataSource = myCommand.ExecuteReader()
        Me.ddlRep.DataTextField = "name"
        Me.ddlRep.DataValueField = "email"
        Me.ddlRep.DataBind()

        Me.ddlRep.Items.Insert( 0, "" )
0
 

Author Comment

by:soweyoung
ID: 12193455
Thanks. That did the trick
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

762 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

21 Experts available now in Live!

Get 1:1 Help Now