473,378 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

DropDownListBox: I want to 'limit to list'

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("c on"))
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

Jun 27 '06 #1
5 1152
OK, sounds good. Are you having a problem? Do you need help? If so, you
might want to tell us more about your problem.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"BJ" <ju**********@yahoo.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
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("c on"))
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

Jun 27 '06 #2
BJ
Hi. I do not want the users to be able to type in an entry that is not
in the list.

Steve C. Orr [MVP, MCSD] wrote:
OK, sounds good. Are you having a problem? Do you need help? If so, you
might want to tell us more about your problem.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"BJ" <ju**********@yahoo.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
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("c on"))
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


Jun 29 '06 #3
In a drop down, you can't type in your own entry. Whats the problem?

BJ wrote:
Hi. I do not want the users to be able to type in an entry that is not
in the list.

Steve C. Orr [MVP, MCSD] wrote:
OK, sounds good. Are you having a problem? Do you need help? If so, you
might want to tell us more about your problem.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"BJ" <ju**********@yahoo.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
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("c on"))
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

Jun 29 '06 #4
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?
Ray Booysen wrote:
In a drop down, you can't type in your own entry. Whats the problem?

BJ wrote:
Hi. I do not want the users to be able to type in an entry that is not
in the list.

Steve C. Orr [MVP, MCSD] wrote:
OK, sounds good. Are you having a problem? Do you need help? If so, you
might want to tell us more about your problem.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"BJ" <ju**********@yahoo.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
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("c on"))
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


Jun 29 '06 #5
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

Jun 30 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Max | last post by:
Have a DropDownListBox where I want to give users the option to select one of the values, but allow them to enter a freeform text value if they choose to do so in lieu of the proffered values. Kind...
7
by: Eduardo M?ndez | last post by:
Hello: I have an aspx page with a TextBox and a DropDownListBox both have Autopostback property set to true and some code in the TextChanged and SelectedIndexChanged events. When text in...
2
by: kgs | last post by:
I dynamically added a DropDownListBox to a footer of datagrid on itemcreated event. In which event in postback can i access the selected item. Interesting thing i noted that even though i create...
4
by: | last post by:
I think we have some bug in dropdownlistbox server control. Following are the values. <asp:DropDownList id="DropDownList1" runat="server"> <asp:ListItem value="46">INR</asp:ListItem>...
1
by: pari kanaga | last post by:
I have server control dropdownlistbox populated with data from table. I don't know how to make this dropdownlistbox searchable. ( for example if i click the dropdownlistbox and type the name it...
1
by: raj | last post by:
hello i want to set the tooltip of data displaying in dropdownlistbox , i have bound the dropdownlistbox with datasource and i want that tooltip shld be display at every item of dropdownlistbox...
1
by: julie6232000 | last post by:
I don't want the users to type in any new items but select only what is on the list. Here's my code to load the ASP:DropDownList: ...
2
by: Kenichi666 | last post by:
I am new to ASP.NET and C#. I have populate a dropdownlistbox from a sqltable. I would like to set the selected value in the dropdownlistbox to an sql UPDATE command. like fx. "UPDATE name =...
1
by: jeyapriya | last post by:
Dear Friends This is Jeyapriya. Right now I am working in the ASP.NET with VB coding & the back end is SQL SERVER 2000. My dilemma is I have to design a form with 2 DropDownListboxes. I have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.