C# 如何在网格中显示移动服务数据?MVC

C# 如何在网格中显示移动服务数据?MVC,c#,asp.net-mvc-4,azure,azure-mobile-services,C#,Asp.net Mvc 4,Azure,Azure Mobile Services,我已经为我的Azure移动服务添加了到MVC站点的连接,我在另一个基于WPF的应用程序中使用了该服务 我不太熟悉如何在移动服务的MVC中显示数据,找不到任何好的例子来说明如何在页面上显示表格数据,例如在网格中 有人知道如何在页面上显示表格日期吗?或者你能告诉我在显示数据时需要采取哪些进一步的步骤吗 主控制器的代码: namespace GesturePhysioWebClient.Controllers { public class HomeController : Controller

我已经为我的Azure移动服务添加了到MVC站点的连接,我在另一个基于WPF的应用程序中使用了该服务

我不太熟悉如何在移动服务的MVC中显示数据,找不到任何好的例子来说明如何在页面上显示表格数据,例如在网格中

有人知道如何在页面上显示表格日期吗?或者你能告诉我在显示数据时需要采取哪些进一步的步骤吗

主控制器的代码:

namespace GesturePhysioWebClient.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Control Panel";

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Patient Progress Details.";

            return View();

        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Contact Us.";

            return View();
        }
    }
}
工具箱未显示任何可添加到以下页面的可用网格控件:

@{
    ViewBag.Title = "About";
}

<hgroup class="title">
    <h1>@ViewBag.Title.</h1>
    <h2>@ViewBag.Message</h2>
</hgroup>

<article>

    <p>
        Patient Records:
        //want to put a grid control or similar here
        //to display the item table records.

    </p>

</article>
显示项目表的Azure连接:


这当然是可能的,但我不确定这是移动服务的最佳使用。 首先确保您已从
NuGet
安装了
Microsoft.WindowsAzure.MobileServices

确保您在HomeController中有对的引用

using Microsoft.WindowsAzure.MobileServices
您的索引方法将如下所示

public async Task<ActionResult> Index()
{
    var mobileClient = new MobileServiceClient("Your mobile service URL",
                                               "Your mobile service access key");
    var itemModelTable = mobileClient.GetTable<ItemModel>();

    var result= await itemModelTable.ToListAsync();

    return View(result);
  }
@model List<ItemModel>
<article>    
    Patient Records:
    //want to put a grid control or similar here
    //to display the item table records.

  @foreach (var element in Model)
  {
    <p>@Html.DisplayFor(m => element.User)</p>
  }

</article>

public async Task

你也可以发布控制器的代码吗?@HuyHoangPham将主控制器添加到上述问题中。接下来我应该采取什么步骤来设置显示数据?
@model List<ItemModel>
<article>    
    Patient Records:
    //want to put a grid control or similar here
    //to display the item table records.

  @foreach (var element in Model)
  {
    <p>@Html.DisplayFor(m => element.User)</p>
  }

</article>