vb.net - How can I retrieve the string value of the selected select element item? -


a previous question here related.

what find need know, though, more specific, namely, how can retrieve string value of selected select element item?

this i'm using grab value:

subcategory = request.form.item("selectsubcategory").tostring() 

...but it's assigning "0" subcategory, no matter item selected.

here everywhere "subcategory" appears in code:

declared:

dim subcategory string 

assigned (as shown above):

subcategory = request.form.item("selectsubcategory").tostring() 

database write:

query2 &= "set subcategory = @subcat " . . . .parameters.add("@subcat", sqldbtype.nvarchar).value = subcategory 

select element code:

<select name="selectsubcategory" color="<%=session("textcolor")%>" style="font: 8pt arial" onchange="updateflag=true;">     <% if not isnewbusiness then%>         <option <% if subcategory = "0" response.write(" selected")%> value="0">existing         <option <% if subcategory = "1" response.write(" selected")%> value="1">organic growth     <% else%>         <option <% if subcategory = "0" response.write(" selected")%> value="0">new         <option <% if subcategory = "1" response.write(" selected")%> value="1">assumed     <% end if%> </select> 

why "0" assigned subcategory? how can assign selected item's text value instead?

update

based on other things have read, thought maybe needed decorate select element "runat="server"" jazz. when did that, so:

<select name="selectsubcategory" runat="server" color="<%=session("textcolor")%>" style="font: 8pt arial" onchange="updateflag=true;"> 

i got this:

parser error  description: error occurred during parsing of resource required service request. please review following specific parse error details , modify source file appropriately.   parser error message: server tags cannot contain <% ... %> constructs.  source error:   line 767:                                        </td> line 768:                                        <td nowrap align="left" valign="top"> line 769:                                            <select name="selectsubcategory" runat="server" color="<%=session("textcolor")%>" style="font: 8pt arial" onchange="updateflag=true;"> line 770:                                            <%--<asp:dropdownlist name="selectsubcategory" color="<%=session("textcolor")%>" style="font: 8pt arial" onchange="updateflag=true;">--%> line 771:                                                <% if not isnewbusiness then%>  source file: /ems/pages/custmaint_entry.aspx    line: 769 

to paraphrase pulitzer-prize-winning hero of hibbing,

update 2

it happened again; no changes code (or, more precisely, trying under sun , reverting tried, didn't work before), works. las campanas del infierno!

i still or having this:

subcategory = request.form.item("selectsubcategory").tostring() 

...and this:

<select name="selectsubcategory" color="<%=session("textcolor")%>" style="font: 8pt arial" onchange="updateflag=true;"> 

...and @ works, whereas didn't before.

i can't tell y'all how glad getting out of programming; don't think stand more week of this. burned out? i'm charred smoldering crisp.


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

c# - Populating Gridview inside Listview ItemTemplate On Web User Control from Code Behind -