Dropdownlist control in ASP.NET
Posted on 2004-09-29
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
Me.ddlRep.DataSource = myCommand.ExecuteReader()
Me.ddlRep.DataTextField = "name"
Me.ddlRep.DataValueField = "email"
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.