asp.net mvc

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
                        join
                        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
   
                        }).ToList();

            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>
    </div>
    <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>ItemID</th>
                                <th>Item Description</th>
                                <th>Current Inventory</th>
                                <th> Count Qty</th>
                               

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

                                </tr>
                                
                            }
                        </table>
                    </form>
                </div>

            </div>
        </div>
    </div>
</div>

Open in new window



Show on the 0 result in UI.


thanks ,
LVL 1
Moti Mashiah.NET DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kblauCommented:
got data:
default controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ReturnList.Controllers
{
    public class DefaultController : Controller
    {
        //
        // GET: /Default/

        public ActionResult Index()
        {
            return View();
        }

    }
}
-----------------
inventory controller
using ReturnList.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ReturnList.Controllers
{
    public class InventoryController : Controller
    {
        //
        // GET: /Inventory/

        public ActionResult Index(int id)
        {
            IList<Countitems> countItems = new List<Countitems>
            {      
                new Countitems{
                     
             
                     
                    CountQty = 5,
                    CurrentInventory = 33,
                    ItemDescription = "AHC",
                    ItemID = 1}
                ,
                new Countitems{
               
                    CountQty = 6,
                    CurrentInventory = 34,
                    ItemDescription = "AHCH",
                    ItemID = 2
                }
            };

            return View(countItems);
        }

    }
}
---------------------------------------
default view
@{
    ViewBag.Title = "Index";
}

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

<input type="button" value="OpenWin" onclick="Showitems(1)" />
----------------------------
inventory view
@model IEnumerable<ReturnList.Models.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>
    </div>
    <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>ItemID</th>
                                <th>Item Description</th>
                                <th>Current Inventory</th>
                                <th> Count Qty</th>


                            </tr>

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

                                </tr>

                            }
                        </table>
                    </form>
                </div>

            </div>
        </div>
    </div>
</div>
--------------------------------
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Moti Mashiah.NET DeveloperAuthor Commented:
Thank you very much for your answer, but I just figured that my code was just fine the only issue was the DB which I fixed.

Thank you soo much for help anyway. i will use your code for the next time.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.