Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
MVC4 Razor( How To get a specific value from database
Jinish Gandhi
Feb 29 2016 3:37 PM
408
Reply
i am using entity data model in mvc 4,i want specific value from dabase like as(select username from Emp where RollId="Textbox1.text")
but in mvc code
______________________________________________________________________
1.[view file code]-->GetResultView
@using(Html.BeginForm("GetResult","Login",FormMethod.Post))
{
<div>
@Html.TextBoxFor(Model=>Model.UserName)
</div>
<div>
@Html.DisplayFor(Model=>Model.RollId)
</div>
<div>
<input type="submit" value="GetResult" name="GetResult">
</div>
}
----------------------------------------------------------------------------------------------------------------------------
2.[Controller]
public ActionResult GetResult()
{
return View();
}
[HttpPost]
public ActionResult GetResult(EmpInfo_Tbl ET)
{
using (db)
{
var v = db.EmpInfo_Tbl.Where(u => u.UserName.Equals(ET.UserName)).Select(u =>u.RollId).FirstOrDefault();
ViewBag.RollId = v.ToString();
}
return View(ET);
}
------------------------------------------------------------------------------------------------------------------------
But in all thing i get value zero...but i didnt get excatly values..so plz help me to find out..:)
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
Is there any future in Windows Forms Application?
I Need To Send File On Server Using SFTP, But It Is Not Work