0

Im trying to retrieve data to a details view on a MVC project. thiw problem i've got Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource. Help ??

this is the code

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
    DetailsView1.DataSource = ViewData["item"];
    DetailsView1.DataBind();

}
</script>

and this is my function in the controller

public ActionResult Details(string  ProdNo)
    {

        ProductionOrderItem item = ProductionOrderReg.GetProductionOrder(con, ProdNo);
        ViewData["item"] = item;
        return View();
    }
4

1 回答 1

0

现在修复了我在函数中添加了一个列表

Public ActionResault Details(string prodNo)
{
ProductionOrderItem item = ProductionOrderReg.GetProductionOrder(con, ProdNo);
        List<ProductionOrderItem> myList = new List<ProductionOrderItem>();
        myList.Add(item);
        ViewData["item"] = myList;
        return View();
}
于 2013-04-24T09:53:52.193 回答