내 문제는 목록입니다 <> 컨트롤러 액션 메서드에서 두 목록에 두 개의 모델을 가져 오는 중 두 개의 목록에 값을 전달하지만 뷰에서 두 개의 목록 값을 전달할 수는 없습니다. 아래 코드를 사용하고 있습니다. 이.mvc 4의 한보기에서 두 모델 목록을 전달하는 방법은 무엇입니까?
projet name Myproject,
my model,
public class table1
{
public int id {get;set;}
public string student_name {get;set;}
}
public class table2
{
public int id {get;set;}
public string roll_number {get;set;}
}
my controller page,
list<table1> t=new list<table1>();
list<table2> t1=new list<table2>();
public ActionResult details()
{
sqlDataAdapter da=new sqldataAdapter("select * from Table1",con);
dataset ds=new dataset();
da.fill(ds);
foreach(datarow dr in ds.Table[0].row)
{
t.add(new table1()
{
id=int.parse(dr[0].ToString()),
student_name=dr[1].ToString()
}
}
sqlDataAdapter da1=new sqldataAdapter("select * from Table2",con);
dataset ds1=new dataset();
da1.fill(ds1);
foreach(datarow dr1 in ds1.Table[0].row)
{
t1.add(new table2()
{
id=int.parse(dr1[0].ToString()),
roll_number=dr1[1].ToString()
}
}
return details(t,t1);
}
view \\\\\\\\\\\\\\\\ My problem in view ,plase help me this problem.
@using MultiSelectList;
@model List<Myproject.Models.table1>
@model List<Myproject.Models.table2>
@{
ViewBag.Title = "Details";
}
<h1>Welcome to details page</h1>
[뷰에서 여러 모델] (의 중복 가능성에 http : // 유래. com/questions/4764011/multiple-models-in-a-view) – DavidG