VS 2012 [RESOLVED] Hlep passing the other model to a partiall view-VBForums
Results 1 to 4 of 4

Thread: [RESOLVED] Hlep passing the other model to a partiall view

  1. #1

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    Resolved [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 30th, 2013 at 12:30 AM.

    If a post has helped you then Please Rate it!

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    97,103

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    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 30th, 2013 at 12:31 AM.

    If a post has helped you then Please Rate it!

  4. #4

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.