I have a question regarding linq query. My controller code looks like this:
public ActionResult Show_Trans(int id = 0)
{
//this checks if the id exists in the database
var check = db.Student_Trans.Where(s=>s.student_id == id).FirstOrDefault();
// if not, show a javascript alert
if(check == null){
return Content("<script type='text/javascript'>alert('No transaction so far.');</script>");
}
// this return the data that equals to the id
return PartialView(db.Payments_vw.Where(s=>s.student_id == id).ToList());
}
In my database view (Payments_vw), for example, the student with student id of 2 has 3 transactions namely: Miscellaneous, Parents Share, Uniform.
The question is: when I tried to view it in my Views, it returns the exact number of rows but the datas are repeated or should I say, all are in Miscellaneous transaction but the Parents Share and Uniform are not shown. Why? Any help is greatly appreciated. Thanks.
Aucun commentaire:
Enregistrer un commentaire