Currently I am able to dynamically populate @Html.DropDownList()
from a dataset. The code below works fine for this.
CONTROLLER
public static IEnumerable<SelectListItem> myList
{
get
{
ReportAPI.ReportsAPI ws = new ReportAPI.ReportsAPI();
DataSet ds = ws.GetReportDataSet(userguid, reportguid);
DataTable dt = ds.Tables[0];
List<SelectListItem> list = new List<SelectListItem>();
foreach (DataRow dr in dt.Rows)
{
list.Add(new SelectListItem
{
Text = dr["text"].ToString(),
Value = dr["value"].ToString(),
});
}
return list;
}
}
public ActionResult NewSubscriber()
{
ViewData["subscriptionplanx"] = myList;
return View();
}
VIEW
@Html.DropDownList("subscriptionplanx")
Now, instead of using a DropDownList, I want to use radio buttons instead. How would I do this?