Hi,
I am developing MVC 5 application. In that I am using Search functionality. I have 3 text boxes and 2 drop down lists in my form, my requirement is enter the text in these fields and the results will display in Grid view. I am using Stored procedure. Now my question is pass the parameters to stored procedure and pass the parameters to controller and display the search results in gridview.
Thank you.
MVC 5 Search Functionality
5 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Guest UserRank #258 · 9.8K pointsPosted Aug 19, 2014, 8:29 AM EDT
neel k103 pointsPosted Aug 19, 2014, 8:42 AM EDT
Thank you for your replay. I am using Entity Framework.
var lstCust = db.Database.SqlQuery<PendingCustomer>("sp_GetPendingCustomers");
This is my stored procedure in Controller.
Thank you.
Guest UserRank #258 · 9.8K pointsPosted Aug 19, 2014, 8:49 AM EDT
var orderId= new SqlParameter("orderid", SqlDbType.Int);
orderId.Value = 1809;
you can execute like this:
neel k103 pointsPosted Aug 20, 2014, 10:32 AM EDT
Guest UserRank #258 · 9.8K pointsPosted Aug 20, 2014, 2:31 PM EDT
http://weblogs.asp.net/dwahlin/using-entity-framework-code-first-with-stored-procedures-that-have-output-parameters
http://msdn.microsoft.com/en-us/library/vstudio/bb896274(v=vs.100).aspx