嗨我是個新來MVC3和我在這裏返回兩個變量有問題是我的控制器代碼如何從控制器返回兩個變量來查看MVC3
public ActionResult Create()
{
using (var context = new material_managementEntities())
{
var blogs = (from cs in context.GROUP_MASTER
where cs.GROUP_NAME == "MIC"
select cs.ID).FirstOrDefault();
var droplist = new TRANSACTION();
droplist.GROUP_MASTER_ID = blogs;
droplist.GROUP_NAME = "MIC";
var directory_master = db.DIRECTORY_MASTER.Include(d => d.CATEGORY_MASTER).Include(d => d.REPRESENTATIVE_MASTER);
droplist.dir_data = directory_master.ToList();
return View(droplist);
}
}
這裏交易是一個表,DIRECTORY_MASTER是另一個和GROUP_MASTER_ID是一個外鍵,事務表,我想是的toList數據將顯示在一個盒子modalpopup所以我需要從兩個表
路過這裏提供的數據模型
namespace Material.Models
{
using System;
using System.Collections.Generic;
using System.Web.Mvc;
public partial class TRANSACTION
{
public int ID { get; set; }
public int GROUP_MASTER_ID { get; set; }
public string GROUP_NAME { get; set; }
public string dir_data { get; set; }
public string NAME { get; set; }
public string ADDRESS_DETAILS { get; set; }
public string CONTACT_PERSON { get; set; }
public Nullable<int> TEL_NO { get; set; }
public Nullable<int> CELL { get; set; }
public Nullable<int> FAX { get; set; }
public string EMAIL_ID { get; set; }
public Nullable<int> OPENING_BALANCE { get; set; }
public Nullable<System.DateTime> OPENING_BALANCE_DATE { get; set; }
public string VERIFIED { get; set; }
public virtual GROUP_MASTER GROUP_MASTER { get; set; }
}
}
你們是不是在視圖訪問導航屬性? – Geethanga
droplist.dir_data = directory_master.ToList();當你的droplist.dir_data是字符串時,你如何能夠分配。 –