Click to See Complete Forum and Search --> : <option value=""> tag


Suzi167
February 20th, 2009, 11:44 AM
Hello,

I need to be able to specify a value in my <option> tag inside of a <select> tag but the value is actually the id of a field.
Here is the code:

<select id="cmbLocation">
<%foreach(EnvironmentalMonitoring.Models.VqEmLocation location in ViewData["locations"] as IEnumerable<EnvironmentalMonitoring.Models.VqEmLocation>)%>
<%{ %>
<option value=""><%=location.Name%></option>
<%} %>
</select>




so where it says <option value = ""> I need to put location.id but I am not sure how the exact syntax should look like

Any help is appreciated

Thanks

Susan

Suzi167
February 20th, 2009, 11:51 AM
I've tried putting <option value="<%=location.id%>"> but it does not like it

sr_jay
February 22nd, 2009, 09:44 PM
Just one question.

Does it have to be a Html Control select control. If you make it a server control like a drop down list it would be much easier. As such the select control is a html control and that is one of the reasons the option tag refuses to accept <%=location.id%>. Let me know.

Warm Regards.
I've tried putting <option value="<%=location.id%>"> but it does not like it