I want to retrieve whole row of data from database when a specific user log in. and show it in my view of profile.
this is my Controller already assigned it a Session variable on ID, I now want to retrieve data from database through this U_ID.
- public ActionResult Index(Account_Details log)
- {
- var obj = db.Account_Details.Where(u => u.Name.Equals(log.Name) && u.Password.Equals(log.Password)).FirstOrDefault();
- if (obj != null)
- {
- Session["loginid"] = obj.U_ID;
- Session["name"] = obj.Name;
- return RedirectToAction("Welcome");
- }
- else
- {
- return View();
- }
- }
- public partial class Account_Details
- {
- public Account_Details()
- {
- this.Basic_Details = new HashSet
(); - }
- public int U_ID { get; set; }
- public string Name { get; set; }
- public string Password { get; set; }
- public string Email { get; set; }
- [DataType(DataType.Date)]
- [MinAge]
- public string DOB { get; set; }
- public virtual ICollection
Basic_Details { get; set; } - }
Gautam ParmarPosted Jan 28, 2018, 9:50 AM