答案 0 :(得分:1)
您可以使用Request.Form []
访问所选值在你的aspx页面中:
<form id="form1" runat="server">
<div id="DivPlant" runat="server" style="float:left">
<asp:Label runat="server" id="lblSelection"></asp:Label>
<asp:Button id="btnSubmit" runat="server" onclick="btnSubmit_Click"/>
</div>
</form>
在你的代码背后:
protected void Page_Load(object sender, EventArgs e)
{
string SelectID = "ddlTest";
string Options = "<option value='volvo'>Volvo</option>";
DivPlant.Controls.Add(new LiteralControl("<select name='ddlName' id='" + SelectID + "'>" + Options + "</select>"));
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblSelection.Text = Request.Form["ddlName"];
}