sangeetha k

sangeetha k

  • 1.7k
  • 207
  • 20.7k

Y am i coulnt redirect to the actionresult in mvc

Apr 19 2018 4:07 AM
i wish to search records in the gridview but it is not redirecting to the method which iam pointing to what would be the problem can any one help me out with this?
 
#Dal
  1. public void SearchRecord(string searchBy,string txtSearch)  
  2. {  
  3. try  
  4. {  
  5. EmployeeEntity emp = new EmployeeEntity();  
  6. using (AdventureWorksEntities empDbentity = new AdventureWorksEntities())  
  7. {  
  8. if ( searchBy=="Name")  
  9. {  
  10. var result=empDbentity.tblEmployees.Where(x=>x.Empname.StartsWith(txtSearch) || txtSearch==null).ToList();  
  11. }  
  12. else{  
  13. var result=empDbentity.tblEmployees.Where(x=>x.Empid==Convert.ToInt32(txtSearch)||txtSearch==null).ToList();  
  14. }  
  15. }  
  16. }  
  17. catch (Exception ex)  
  18. {  
  19. Log.WriteError("BorrowerImageGridView.EmployeeDataAcess.searchRecord()", ex);  
  20. throw new Exception(TUtil.GetMethodExceptionContext(searchBy, txtSearch), ex);  
  21. }  
#bll
  1. public void SearchRecord(string searchBy, string txtSearch)  
  2. {  
  3. try  
  4. {  
  5. empdata.SearchRecord(searchBy, txtSearch);  
  6. }  
  7. catch (Exception ex)  
  8. {  
  9. throw new Exception(TUtil.GetMethodExceptionContext(searchBy, txtSearch), ex);  
  10. }  
  11. }  
#contoller
  1. [HttpGet]  
  2. public ActionResult SearchRecord(string searchBy,string txtSearch)  
  3. {  
  4. empservice.SearchRecord(searchBy,txtSearch);  
  5. return RedirectToAction("EmployeeDetails");  
  6. }  
#view
  1. @using (Html.BeginForm("SearchRecord"" Employee", FormMethod.Get))  
  2. {  
  3. <div>  
  4. <div class="input-group">  
  5. <b>Search By:</b>  
  6. @Html.RadioButton("searchBy""Empname"true)Name  
  7. @Html.RadioButton("searchBy""Empid")EmployeeId  
  8. @Html.TextBox("txtSearch"""new { @id = "txtSearch", @class = "form-control", style = " margin-bottom: 25px ;align-content:center; font-family:Arial, FontAwesome", placeholder = "Search" })  
  9. @*<input type="text" class="form-control" id="txtSearch" placeholder="Search for...">*@  
  10. <span class="input-group-btn">  
  11. <button id="btnSearch"class="btn btn-secondary" style="margin-bottom:4px;"type="submit"><i class="glyphicon glyphicon-search"></i></button>  
  12. </span>  
  13. </div>  
  14. @*<input id="txtSearch" style=" margin-bottom: 25px ;font-family:Arial, FontAwesome" type="text" placeholder=" ? Search " name=" search">  
  15. <button type="button" class="btn btn-info" style=" margin-bottom: 25px">  
  16. <span class=" glyphicon glyphicon-search">  
  17. </span> Search  
  18. </button>*@  
  19. </div>  
  20. }  

Answers (3)