soweyoung
asked on
Dropdownlist control in ASP.NET
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(myConnStrin g)
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
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(myConnStrin
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER