Im trying to get a value or a text from the “select option” tag through C#, but I run on some issues :
this is my code :
<select id="country" >
<option value="" >Select One...</option>
<%for (int i = 0; i < dt.Rows.Count; i++)
{%>
<option value="<%=dt.Rows[i][0].ToString() %>" ><%=dt.Rows[i][1].ToString() %></option>
<%} %>
</select>
and this is my code behind :
string value = Request.Form.Get("country");
its keep getting null in my value. and if Im trying to set my <select> tag with runat="server", its getting an error :
Code blocks are not supported in this context
any help?
Thanks!
Form elements are posted by their name attribute, not id.
Try