We help IT Professionals succeed at work.
Get Started

asp.net mvc

Moti Mashiah
Moti Mashiah asked
Last Modified: 2015-04-28
Hi Guys ,

I have some MVC app and I'm trying to return list  to the model view  and it is return 0. I'm wondering where i'm wrong.

Here is  how I wrote the code:

First I let user to click button and get popup window and pass id:

 function Showitems(id) {
            var url = "@System.Configuration.ConfigurationManager.AppSettings["webUrl"]";
            url = url + "Inventory/Itemsrefer/" + id;
            window.open(url, '_blank',"width=1200, height=800", 'resizable=No');

Open in new window

My Controller:
public ActionResult Itemsrefer(int id)
            mpsonCRMEntities db = new mpsonCRMEntities();

            var refi = (from i in db.t_InventoryCountEntry
                        e in db.t_InventoryCount on i.InventoryCountID equals e.ID
                        where i.InventoryCountID == id
                        select new Countitems
                         ItemID = i.ItemID,
                         Itemlookupcode = i.Itemlookupcode,
                         ItemDescription = i.ItemDescription,
                         CurrentInventory = i.CurrentInventory,
                         CountQty = i.CountQty

            return View(refi);

Open in new window

My View:
@model IEnumerable<ALThompsonCRM.Models.ViewModel.Countitems>

<div class="panel panel-default">
    <!-- Default panel contents -->
    <div class="panel-heading">
        Items Refers
        <div class="btn-group pull-right">
            @*<a class="btn btn-primary btn-sm" title="Update data" onclick="SaveAllItems();" href="#">Update</a>*@
    <div class="panel-body">
        <div id="table-content" class="table-responsive">
            <div id="content-table-inner">
                <div id="table-content">
                    <form id="poitems">
                        <table class="table table-bordered">
                            <tr style="background-color: silver;">
                                <th>Item Description</th>
                                <th>Current Inventory</th>
                                <th> Count Qty</th>

                            @foreach (var item in Model)
                                    <td>@item.ItemID  </td>
                                    <td>@item.ItemDescription  </td>
                                    <td style="text-align: center">@item.CurrentInventory </td>
                                    <td style="text-align: center">@item.CountQty



Open in new window

Show on the 0 result in UI.

thanks ,
Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE