Solved

Dropdownlist control in ASP.NET

Posted on 2004-09-29
2
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

726 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