-
May 29th, 2013, 10:04 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Hlep passing the other model to a partiall view
ASP.NET Framework 4.0 MVC C#
I have created a 2 model in a class and pass it to view and the other to a partial view. But the partial always return exception.
it is something like this:
Code:
//my class
public class myIndexData
{
//display record details
public stp_Student_Result StudentDetail { get; set; }
//display record sublist display (note: all of my table is joined/related dynamically/only in my stored procedure)
public List<stp_Courses_Result> CourseLists { get; set; }
}
//in my controller:
var myIndexData= new myIndexData()
{
StudentDetail = Db.stp_Student(id).Single(),
CourseLists = Db.stp_Courses(id).ToList()
};
return View(myIndexData);
//in my view
@model SWB2MVC.Models.myIndexData
@Model.StudentDetail.Name // this works displaying the main record model!
@Html.Partial("_partialpage", Model.CourseLists) = this one throw exceptions!
//in my partial view
@model IList<stp_Courses_Result>
pls give advice. TIA
Last edited by VBKNIGHT; May 29th, 2013 at 11:30 PM.
If a post has helped you then Please Rate it!
-
May 29th, 2013, 10:37 PM
#2
Re: Hlep passing the other model to a partiall view
Any particular reason that you thought it would be a good idea to tell us that an exception occurred but not provide any more information about it, like the type of exception, the error message and the call stack?
-
May 29th, 2013, 11:20 PM
#3
Thread Starter
Fanatic Member
Re: Hlep passing the other model to a partiall view
sorry here's the error:
Code:
_partialpage.cshtml(19): error CS1061:
'System.Collections.Generic.IEnumerable<TestMVC.Models.stp_Courses_Result>'
does not contain a definition for 'ID' and no extension method 'ID'
accepting a first argument of type
'System.Collections.Generic.IEnumerable<TestMVC.Models.stp_Courses_Result>'
could be found (are you missing a using directive or an assembly reference?)"}
Last edited by VBKNIGHT; May 29th, 2013 at 11:31 PM.
If a post has helped you then Please Rate it!
-
May 29th, 2013, 11:37 PM
#4
Thread Starter
Fanatic Member
Re: [RESOLVED] Hlep passing the other model to a partiall view
already resolved this one. it seems that i missed out some id declaration in my view page that should not be there. thanks
If a post has helped you then Please Rate it!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|