By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,114 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,114 IT Pros & Developers. It's quick & easy.

get values from drop down

P: n/a
I have a drop down on my form and I need all the values in that drop down
and pass to a stored procedure, how can I get the values of the drop down
and pass them all to my stored procedure call?

May 31 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You can't do that from a simple drop-down control because these values
are not posted on the server. If you are talking about a server side
drop-down, then enumerating through Items property for the ListItems of
the control should give you the values.

Regards,
Tasos
John wrote:
I have a drop down on my form and I need all the values in that drop down
and pass to a stored procedure, how can I get the values of the drop down
and pass them all to my stored procedure call?


May 31 '06 #2

P: n/a
Do you mean including the none-selected ones?

If it's a server control (ie, asp:dropdownlist) and you enable viewstate
(which it is by default), you can simply loop through it's item collection..

for each item as ListItem in myDropDown.Items
dim value as string = item.Value
..do something
end for

Otherwise, you'll need to use javascrit to highlight every item onSubmit and
use Request.Form

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"John" <wh****@gmail.com> wrote in message
news:OZ**************@TK2MSFTNGP05.phx.gbl...
I have a drop down on my form and I need all the values in that drop down
and pass to a stored procedure, how can I get the values of the drop down
and pass them all to my stored procedure call?

May 31 '06 #3

P: n/a
its a user control:
<asp:DropDownlList id="ddCars" runat="server"></asp:DropDownList>
when I do a foreach I get an error message
"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
You can't do that from a simple drop-down control because these values
are not posted on the server. If you are talking about a server side
drop-down, then enumerating through Items property for the ListItems of
the control should give you the values.

Regards,
Tasos
John wrote:
I have a drop down on my form and I need all the values in that drop down
and pass to a stored procedure, how can I get the values of the drop down
and pass them all to my stored procedure call?

May 31 '06 #4

P: n/a
Would you like to post your error message and the code?

John wrote:
its a user control:
<asp:DropDownlList id="ddCars" runat="server"></asp:DropDownList>
when I do a foreach I get an error message
"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
You can't do that from a simple drop-down control because these values
are not posted on the server. If you are talking about a server side
drop-down, then enumerating through Items property for the ListItems of
the control should give you the values.

Regards,
Tasos
John wrote:
I have a drop down on my form and I need all the values in that drop down
and pass to a stored procedure, how can I get the values of the drop down
and pass them all to my stored procedure call?


May 31 '06 #5

P: n/a
Error:

Error 5 foreach statement cannot operate on variables of type
'ASP.usercontrols_carMakes_ascx' because 'ASP.usercontrols_carMakes_ascx'
does not contain a public definition for 'GetEnumerator'

code on my form that has the user control on it:

void btnGo_Click(object sender, EventArgs e)
{
foreach (ListItem items in CarMake)
{
Response.Write(items.Value);
}
}
and this is a dropdown box not a listbox

"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Would you like to post your error message and the code?

John wrote:
its a user control:
<asp:DropDownlList id="ddCars" runat="server"></asp:DropDownList>
when I do a foreach I get an error message
"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
You can't do that from a simple drop-down control because these values
are not posted on the server. If you are talking about a server side
drop-down, then enumerating through Items property for the ListItems of
the control should give you the values.

Regards,
Tasos
John wrote:
I have a drop down on my form and I need all the values in that drop
down
and pass to a stored procedure, how can I get the values of the drop
down
and pass them all to my stored procedure call?


May 31 '06 #6

P: n/a
John wrote:
Error:

Error 5 foreach statement cannot operate on variables of type
'ASP.usercontrols_carMakes_ascx' because 'ASP.usercontrols_carMakes_ascx'
does not contain a public definition for 'GetEnumerator'

code on my form that has the user control on it:

void btnGo_Click(object sender, EventArgs e)
{
foreach (ListItem items in CarMake)
{
Response.Write(items.Value);
}
}
and this is a dropdown box not a listbox Well, no its neither. As the error message shows, CarMake is of type
ASP.usercontrols_carMakes_ascx which is a user control that either you
or your team has developed.

Without further code as to the properties of this usercontrol, we can go
no further.

Kind Regards
Ray


"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Would you like to post your error message and the code?

John wrote:
its a user control:
<asp:DropDownlList id="ddCars" runat="server"></asp:DropDownList>
when I do a foreach I get an error message
"Tasos Vogiatzoglou" <tv*****@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
You can't do that from a simple drop-down control because these values
are not posted on the server. If you are talking about a server side
drop-down, then enumerating through Items property for the ListItems of
the control should give you the values.

Regards,
Tasos
John wrote:
> I have a drop down on my form and I need all the values in that drop
> down
> and pass to a stored procedure, how can I get the values of the drop
> down
> and pass them all to my stored procedure call?

May 31 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.