Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another question on DropDown Lists

Status
Not open for further replies.

gregburningham

Programmer
Jul 12, 2000
40
GB
I would like to put in a blank line into the dropdown list but I want to avoid a query with a UNION statement in it that adds the line (with NULL values in it) !

Please could you let me know if I can do this through the code rather than through the query.

I also want to use:

vDropDownList.Items.FindByValue(listValue).Selected = True

without errors being thrown ...

PLEASE CAN ANYONE HELP ?

THANKS IN ADVANCE ......

 
Before populating the list add this line of code for your blank line:

[tt]
vDropDownList.Items.Add("")
[/tt]
 
Thanks Brian

I tried it - but it doesn't seem to work in this section of code ....

Public Sub BuildArrayList(ByVal blankLine As Boolean, ByVal oraConnectionStr As String, ByVal sqlStr As String _
, ByVal vDropDownList As DropDownList, ByVal listValue As String)
' attempt to pass in and return the ListItem Object itself

Dim newArrayList As New ArrayList()
Dim newArrayListValue As New ArrayList()
' Dim newArrayList As MyArrayList
Dim createArrayException As Exception
Dim createArrayListCommand As New OleDb.OleDbCommand()
Dim oraConnection As New OleDb.OleDbConnection()
Dim arrayListDataReader As OleDb.OleDbDataReader


Try
'Get the Oracle connection string.
oraConnection.ConnectionString = oraConnectionStr
createArrayListCommand.Connection = oraConnection

'Open the Oracle connection.
oraConnection.Open()

'Build the Status LOV from a SQL statement.
createArrayListCommand.CommandText = sqlStr
createArrayListCommand.CommandType = CommandType.Text

vDropDownList.Items.Add("")

arrayListDataReader = createArrayListCommand.ExecuteReader()

vDropDownList.DataSource = arrayListDataReader
vDropDownList.DataTextField = "code_desc"
vDropDownList.DataValueField = "code"
vDropDownList.DataBind()
vDropDownList.Items.FindByValue(listValue).Selected = True


arrayListDataReader.Close()

Catch createarrayException
exceptionMessageStr = createArrayException.Message.ToString()

Finally
'Close the Oracle connection.
oraConnection.Close()
End Try
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top