html select like drop down list

N

nasirmajor

Dear all,
a simple quetion as usual
I have a html select list. e.g
<select class="text" name="bmonth" runat="server" id="bmonth">
<option selected="selected"
value="0"></option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>

and sql database in which i want to save the text of the selected month
from this html select control. like

co.Parameters.Add(new SqlParameter("@month", SqlDbType.VarChar,
50));
co.Parameters["@month"].Value = bmonth.????????? ;
^
what should come inplase of ???????????
drop down list works fine with dropdownlistname.selecteditem.text;
but how this should be done with html select.
thanks in advance
 
M

Mark Rae

what should come inplase of ???????????

bmonth.SelectedValue; will return "1", "2" etc
bmonth.SelectedItem.Text will return "January", "February" etc
 
N

nasirmajor

Mark said:
bmonth.SelectedValue; will return "1", "2" etc
bmonth.SelectedItem.Text will return "January", "February" etc

Dear Rae,
im using vstudio express2005 and in that there is no option availible
like
bmonth.SelectedItem.Text for html select. this is availible only for
server
control i.e dropdown list
 
N

nasirmajor

Dear myself
i think its not possible without this

protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "You selected: ";

for (int i = 0; i <= bmonth.Items.Count-1; i++)
{
if (bmonth.Items.Selected)
Label1.Text += " -" + bmonth.Items.Text;
}


}

regard
myself
 
M

Mark Rae

Dear Rae,

No need to be so formal - Mark will do...:)
im using vstudio express2005 and in that there is no option availible
like
bmonth.SelectedItem.Text for html select. this is availible only for
server
control i.e dropdown list

Oh right - now I see what you mean. Obviously, an easy way to get round your
problem would be to use a server-side DropDownList - is there any particular
reason you can't do that...?
 
N

nasirmajor

ThankYou Dear Mark,
yes dear there is a big reasion:
the resion is: i have a big list box of more than 200 countries already
filled and i did'nt want
to fill the drop down list with that 200 countries.
thats why i asked the quetion
however new code is working.
if you have any smaller version
it will be my pleasure to use that.
thanks.
regards
nasir.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top