Guest User

Untitled

a guest
Dec 3rd, 2018
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. public ActionResult Index(string Searching)
  2. {
  3. return View(db.Students.Where(x => x.StudentName.StartsWith(Searching) || Searching == null).ToList());
  4. }
  5.  
  6.  
  7.  
  8.  
  9.  
  10. @model IEnumerable<WebApplication1.Models.Student>
  11.  
  12.  
  13.  
  14. <br />
  15. <br/>
  16. @using (Html.BeginForm("Index", "Home", FormMethod.Get))
  17. {
  18. @Html.TextBox("Searching")<input type="submit" value="Search"/>
  19. }
  20. <table class="table table-striped">
  21. <thead>
  22. <tr>
  23. <th>Student Id</th>
  24. <th>Student Name</th>
  25. <th>Gender</th>
  26. <th>Class</th>
  27. <th>Contact</th>
  28. <th>BloodGroup</th>
  29. <th>Address</th>
  30.  
  31. </tr>
  32. </thead>
  33. <tbody>
  34. @if(Model.Count()==0)
  35. {
  36. <tr>
  37. <td colspan="3" style="color:red">No match Found</td>
  38.  
  39. </tr>
  40. }
  41. else
  42. {
  43. foreach (var item in Model)
  44. {
  45. <tr>
  46. <td>@item.StudentID</td>
  47. <td>@item.StudentName</td>
  48. <td>@item.Gender</td>
  49. <td>@item.Class</td>
  50. <td>@item.Contact</td>
  51. <td>@item.BloodGroup</td>
  52. <td>@item.Address</td>
  53. </tr>
  54.  
  55. }
  56. }
  57. </tbody>
  58.  
  59. </table>
Add Comment
Please, Sign In to add comment