ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.Populate DropDown, RadioButton, CheckBox from Database using model and without model in ASP.Net MVC<p>Hi&nbsp;<a class="username" rel="rani">rani,</a></p> <p>Refer the below articles.</p> <ul> <li class="header"><a title="Bind (Populate) DropDownList from database using Model in ASP.Net MVC Razor'a" href="http://www.aspsnippets.com/Articles/Bind-Populate-DropDownList-from-database-using-Model-in-ASPNet-MVC-Razor.aspx">Bind (Populate) DropDownList from database using Model in ASP.Net MVC Razor</a></li> <li class="header"><a title="Bind (Populate) RadioButtonList from database using Model in ASP.Net MVC Razor'a" href="http://www.aspsnippets.com/Articles/Bind-Populate-RadioButtonList-from-database-using-Model-in-ASPNet-MVC-Razor.aspx">Bind (Populate) RadioButtonList from database using Model in ASP.Net MVC Razor</a></li> <li class="header"><a title="Bind (Populate) CheckBoxList from database using Model in ASP.Net MVC Razor'a" href="http://www.aspsnippets.com/Articles/Bind-Populate-CheckBoxList-from-database-using-Model-in-ASPNet-MVC-Razor.aspx">Bind (Populate) CheckBoxList from database using Model in ASP.Net MVC Razor</a></li> </ul>http://www.aspforums.net/Threads/114570/Populate-DropDown-RadioButton-CheckBox-from-Database-using-model-and-without-model-in-ASPNet-MVC/http://www.aspforums.net/Threads/114570/Populate-DropDown-RadioButton-CheckBox-from-Database-using-model-and-without-model-in-ASPNet-MVC/Tue, 29 Nov 2016 23:04:48 GMTPopulate DropDown, RadioButton, CheckBox from Database using model and without model in ASP.Net MVC<p>Hi dharmendr</p> <p>Good expalnation with sample. The dropdown&nbsp;sample is using model. How to bind the dropdown without using&nbsp;model?</p>http://www.aspforums.net/Threads/114570/Populate-DropDown-RadioButton-CheckBox-from-Database-using-model-and-without-model-in-ASPNet-MVC/http://www.aspforums.net/Threads/114570/Populate-DropDown-RadioButton-CheckBox-from-Database-using-model-and-without-model-in-ASPNet-MVC/Tue, 29 Nov 2016 23:36:33 GMTPopulate DropDown, RadioButton, CheckBox from Database using model and without model in ASP.Net MVC<p>Hi rani,</p> <p>Refer the below code. You have to use ViewData to pass the list of items to the view page.</p> <p><span style="text-decoration: underline;">Controller</span></p> <pre class="brush: csharp">public ActionResult Index() { List&lt;SelectListItem&gt; items = new List&lt;SelectListItem&gt;(); // Populate from database. items.Add(new SelectListItem() { Text = &#34;Test 1&#34;, Value = &#34;1&#34; }); items.Add(new SelectListItem() { Text = &#34;Test 2&#34;, Value = &#34;2&#34; }); items.Add(new SelectListItem() { Text = &#34;Test 3&#34;, Value = &#34;3&#34; }); items.Add(new SelectListItem() { Text = &#34;Test 4&#34;, Value = &#34;4&#34; }); items.Add(new SelectListItem() { Text = &#34;Test 5&#34;, Value = &#34;5&#34; }); items.Add(new SelectListItem() { Text = &#34;Test 6&#34;, Value = &#34;6&#34; }); ViewData[&#34;ddl&#34;] = items; return View(items); }</pre> <p><span style="text-decoration: underline;">View</span></p> <pre class="brush: html">&lt;div&gt; &nbsp;&nbsp;&nbsp; &lt;%:Html.DropDownList("Test",(IEnumerable&lt;SelectListItem&gt;)ViewData["ddl"],"Select") %&gt; &nbsp;&nbsp;&nbsp; &lt;br /&gt; &nbsp;&nbsp;&nbsp; &lt;br /&gt; &nbsp;&nbsp;&nbsp; &lt;table border="1"&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%foreach (SelectListItem item in (IEnumerable&lt;SelectListItem&gt;)ViewData["ddl"]) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {%&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;tr&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%:Html.CheckBox("Test", item.Selected, item.Value)%&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%:Html.Label(item.Text)%&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%:Html.Hidden(item.Value)%&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/td&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;td&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%:Html.RadioButton("Item", item.Value,item.Selected, "")%&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%:Html.Label(item.Text)%&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/td&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/tr&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%}%&gt; &nbsp;&nbsp;&nbsp; &lt;/table&gt; &lt;/div&gt;</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/114570/Populate-DropDown-RadioButton-CheckBox-from-Database-using-model-and-without-model-in-ASPNet-MVC/http://www.aspforums.net/Threads/114570/Populate-DropDown-RadioButton-CheckBox-from-Database-using-model-and-without-model-in-ASPNet-MVC/Wed, 30 Nov 2016 07:02:26 GMTPopulate DropDown, RadioButton, CheckBox from Database using model and without model in ASP.Net MVC<p>Thank you.</p>http://www.aspforums.net/Threads/114570/Populate-DropDown-RadioButton-CheckBox-from-Database-using-model-and-without-model-in-ASPNet-MVC/http://www.aspforums.net/Threads/114570/Populate-DropDown-RadioButton-CheckBox-from-Database-using-model-and-without-model-in-ASPNet-MVC/Wed, 30 Nov 2016 22:39:09 GMT