我有一个动态dropdrownlist,我想将所选值从下拉列表传递给控制器
ModelBEL.cs
public class ModelBEL
{
public static string exmId { get; set; }
public static string qus { get; set; }
public static string ans1 { get; set; }
public static string ans2 { get; set; }
public static string ans3 { get; set; }
public static string ans4 { get; set; }
public DataSet exmAllData { get; set; }
}
数据库图层类
public class dbEngine
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
SqlCommand cmd = null;
SqlDataAdapter sda = null;
DataSet ds = null;
public DataSet getExamQus()
{
sda = new SqlDataAdapter("usp_getAllExam", con);
ds = new DataSet();
sda.Fill(ds);
return ds;
}
}
查看
<select id="ddl1">
<option>select</option>
@for (int i = 0; i < @Model.exmAllData.Tables[0].Rows.Count; i++)
{
<option>@Model.exmAllData.Tables[0].Rows[i][0].ToString()</option>
}
</select>
我使用下拉列表
@Html.DropDownList("exam", "choose Tournament")
如何将所选值从下拉列表传递给控制器