I have something like that:
<asp:ListView ID="lvList" runat="server">
<LayoutTemplate>
<select id="select_list">
<option value="-1">
select one
</option>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
</select>
</LayoutTemplate>
<ItemTemplate>
<option value="<%# Eval("code") %>">
<%# Eval("Name") %>
</option>
</ItemTemplate>
</asp:ListView>
And I want to access select_list
at server side, after a button get submitted..
I tried FindControl("select_list")
, lvList.FindControl("select_list")
, Request.Form["select_list"]
- none of them gave my the control back..
Is there some way to get the control by its id, just like JS getElementByID
?
Thanks.
Is this for academic purpose? You could write the same code with lesser markup using an asp:DropDownList
<asp:DropDownList ID="select_list" runat="server"
AppendDataBoundItems="true"
DataTextField="Name"
DataValueField="code">
<asp:ListItem Text="select one" Value="-1" />
</asp:DropDownList>
If you are particular about using ListView do run your HTML Control at server runat="server"