不包含get enumerator的公共定义

时间:2017-10-26 07:04:31

标签: model-view-controller

我的观点陈述显示错误"对于每个语句,不能对“公共定义”类型的变量进行操作“get enumerator' " 我在模型和视图模型中定义了所有对象。我仍然得到这个错误。对此有何解决方案?

我的观点:

 @using Edi.ViewModel
    @model viewmodel
    @{
        <link rel="stylesheet" type="text/css" href="~/Content/style.css" />
                    Layout = null;

    }
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link href="~/Content/Site.css" rel="stylesheet" />
        <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
        <link href="~/Content/bootstrap.css" rel="stylesheet" />
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

    </head>
    <body>

        <form id="form1" name="zoo">
            <div class="med">
                <pre> 
     <fieldset id="field1">
     <legend>Bill Date Range</legend>
     <input type="checkbox">After  <input type="date" />  <input type="checkbox">Before  <input type="date" />
     </fieldset>&nbsp;&nbsp;&nbsp;&nbsp;
                <fieldset id="field2">
                    <legend>Options</legend>
                    <label>Facility</label>  @Html.DropDownListFor(Model => Model.Facility, Model.Facility, "Select Facility", new { style = "width:200px; height :30px" }) 
                    <label>Ins Queue</label>  @Html.DropDownListFor(Model => Model.InsQueue, Model.InsQueue, "Select InsQueue", new { style = "width:200px; height:30px" })
                    Claim type  <select style="width: 100px; height:30px"><option value="ALL">All</option><option value="NEW">New</option><option value="RESUBMIT">Resubmit</option></select>
                </fieldset>
                <pre>
                    <label>No of Bills Selected </label><input type="text" size="1" /> <label> EDI send To </label> @Html.DropDownListFor(Model => Model.EdiSendTo, Model.EdiSendTo, "Select Edi", new { style = "width:200px; height :30px" })  <button type="button" onclick="">Select All</button> <button type="reset" onclick="">Refresh</button> <button type="button" onclick="">Clear All</button> <button type="button" onclick="">Edit Bill</button>
               </pre>
                <table id="myTable">
                    <tr class="hd">
                        <th>visit</th>
                        <th>billno</th>
                        <th>patient</th>
                        <th>providername</th>
                        <th>insname</th>
                        <th>payby</th>
                        <th>inscode</th>
                        <th>user</th>
                        <th>claimtype</th>
                    </tr>
-------------------@foreach (var items in Model)------------------------------
                {
                        <tr onclick="javascript:showRow1(this);">
                            <td>@items.visit</td>
                            <td>@items.billno</td>
                            <td>@items.Patient</td>
                            <td>@items.ProviderName</td>
                            <td>@items.InsName</td>
                            <td>@items.PayBy</td>
                            <td>@items.InsCode</td>
                            <td>@items.User</td>
                            <td>@items.ClaimType</td>
                        </tr>
                    }
                </table>
    </div>
            </form>
                </body>
    </html>

我的控制者:

namespace Edi.Controllers
{
    public class HomeController :Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            mbill mt = new mbill();
            billing db = new billing();
            viewmodel vm = new viewmodel();
            vm.Facility = db.Add1();
            vm.EdiSendTo = db.Add2();
            vm.InsQueue = db.Add3();
            List<mbill> itemlist = new List<mbill>();
            itemlist = db.Index();
            return View("Index",vm);

        }

    }
}

我的模特:

public List<mbill> Index()
        {
            List<mbill> itemList = new List<mbill>();
            connection();
            SqlCommand cmd = new SqlCommand("procGetEDIBills", con);
            cmd.CommandType = CommandType.StoredProcedure;
            con.Open();
            SqlDataAdapter sd = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            sd.Fill(dt);

            mbill item = new mbill();

            using (SqlDataReader sdr = cmd.ExecuteReader())
            {
                mbill io = new mbill();
                while (sdr.Read())
                {
                    io = new mbill();
                    io.visit = sdr["VisitDate"].ToString();
                    io.billno = sdr["Billno"].ToString();
                    io.Patient = sdr["PatientName"].ToString();
                    io.ProviderName = sdr["ProviderName"].ToString();
                    io.InsName = sdr["InsuranceName"].ToString();
                    io.PayBy = sdr["BillPayBy"].ToString();
                    io.InsCode = sdr["InsuranceId"].ToString();
                    io.User = sdr["QueueByUser"].ToString();
                    io.ClaimType = sdr["ClaimType"].ToString();
                    itemList.Add(io);
                }
            }
            con.Close();
            return itemList;
        }
    }

如果我在视图上删除@using Edi.ViewModel,@ model viewmodel,则foreach错误消失,dropdownlistfor shows不包含dropdownlistfor error的定义。

0 个答案:

没有答案