Skip to content
Loading
MVC, value passed from view to controller, EF sleeping?
  • Jaganathan Bantheswaran
    Hi,


    Try to pass null as the fourth parameter.

    @Html.ActionLink(subcategory.S_Description, "BookPDF", new { subid = subcategory.S_SubId }, null)
  • Hi Jaganathan,


    Thanks for the reply.


    Yes, I did debug. But I don't understand.


    If I put break point on that line, nothing will happen because it will not get called. For unknown reason, s_subId is equal to null. So, my checking of

    if (s_subId != null) ...else return View();

    will direct the program to run the next line instead of the line i put break point on.

    But, if you look at my attached print screen, you will find that there is a value '1002' in the URL, which is passed from view (SubCategory).

    I did also include a print screen of my database query result in the same attachment, which shows that i have data in the database. I just don't understand where did i do wrong so that EF do not pick up the book title from database.

    Regards
  • Jaganathan Bantheswaran
    Did you debug the Code? what was the result when you put break point on 

    var bookdetails = db.BookDetails.Include("BookPDF").Single(b => b.B_SubId == s_subId);

    Does bookdetails has anything?? Did you the collection BookDetails??