ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.ASP.Net MVC Error: Only one model statement is allowed in a file<p>Hi&nbsp;nedash,</p> <p>Refer below code.</p> <p><strong><span style="text-decoration: underline;">Model</span></strong></p> <pre class="brush: csharp">public class SearchViewModel { public IEnumerable&lt;Reseller&gt; Reseller1 { get; set; } public DataTable Reseller { get; set; } public List&lt;SelectListItem&gt; Ostans { get; set; } public List&lt;SelectListItem&gt; Citeies { get; set; } }</pre> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { var model = new SearchViewModel(); model.Ostans = PopulateOstan(); model.Citeies = PopulateCiteies1(); model.Reseller = PopulateReseller(); return View(model); } private static List&lt;SelectListItem&gt; PopulateOstan() { return new List&lt;SelectListItem&gt;(); } private static List&lt;SelectListItem&gt; PopulateCiteies1() { return new List&lt;SelectListItem&gt;(); } private static DataTable PopulateReseller() { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn(&#34;Name&#34;), new DataColumn(&#34;Address&#34;) }); dt.Rows.Add(&#34;John Hammond&#34;, &#34;United States&#34;); dt.Rows.Add(&#34;Mudassar Khan&#34;, &#34;India&#34;); dt.Rows.Add(&#34;Suzanne Mathews&#34;, &#34;France&#34;); dt.Rows.Add(&#34;Robert Schidner&#34;, &#34;Russia&#34;); return dt; } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;%@ Page Language=&#34;C#&#34; Inherits=&#34;System.Web.Mvc.ViewPage&lt;_DataSet_ViewModel_MVC.Models.SearchViewModel&gt;&#34; %&gt; &lt;%@ Import Namespace=&#34;System.Data&#34; %&gt; &lt;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&gt; &lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head runat=&#34;server&#34;&gt; &lt;title&gt;Index&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id=&#34;divSearch&#34;&gt; &lt;table class=&#34;table-full table-total&#34;&gt; &lt;% foreach (DataRow row in Model.Reseller.Rows) {%&gt; &lt;tr&gt; &lt;td&gt;&lt;%=row[&#34;Name&#34;] %&gt;&lt;/td&gt; &lt;td&gt;&lt;%=row[&#34;Address&#34;] %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% }%&gt; &lt;/table&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/9fkwmzT.jpg" alt="" width="252" height="167" /></span></strong></p>https://www.aspforums.net:443/Threads/117884/ASPNet-MVC-Error-Only-one-model-statement-is-allowed-in-a-file/https://www.aspforums.net:443/Threads/117884/ASPNet-MVC-Error-Only-one-model-statement-is-allowed-in-a-file/Mon, 03 Jun 2019 05:02:43 GMT