DropDownListBox: I want to 'limit to list'

B

BJ

I do not want the users to enter in any new items but only select from
the list I provide for them: Here is my code



'----------------------------------------------------------------------------
'-- ADD ITEMS TO THE TYPE DROP DOWN BOX

'----------------------------------------------------------------------------
sqlCMD.Connection = New
SqlConnection(ConfigurationSettings.AppSettings("con"))
sqlCMD.CommandType = CommandType.StoredProcedure
sqlCMD.CommandText = "usp_GetAppType"
'sqlCMD = New SqlCommand("SELECT DISTINCT APL_TYP_C FROM
dbo.TCPRDA ORDER BY APL_TYP_C", con)

sqlCMD.Connection.Open()
myReader = sqlCMD.ExecuteReader()

If myReader.HasRows Then
'Add blank first item. Note this will be the default
selection but user must select another value
Me.ddlType.Items.Add("")
Do While myReader.Read()
i = New ListItem(myReader.GetString(0))
Me.ddlType.Items.Add(i)
Loop
Else
i = New ListItem("No items returned")
Me.ddlType.Items.Add(i)
End If

myReader.Close()
sqlCMD.Connection.Close()

'Remove ALL from the type of application drop down list
Me.ddlType.Items.Remove("ALL")
Me.ddlType.SelectedIndex = 0
 
S

Steve C. Orr [MVP, MCSD]

OK, sounds good. Are you having a problem? Do you need help? If so, you
might want to tell us more about your problem.
 
B

BJ

Our users can. And its NOT a custom control. I used the DropDownList
control from VS2003. Its an Corporate Intranet site so I cant let you
try it. The only thing that comes to my mind is the way I did late
binding?
 
B

BJ

Ok when I take the application and database home and recomplie and run
it there, I can not enter any text in the drop down list control.
We'll be rebuilding our web server later today. I know that doesn't
tell me the problem, it should correct it.

Thanks everyone
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top