Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult Index(string Searching)
- {
- return View(db.Students.Where(x => x.StudentName.StartsWith(Searching) || Searching == null).ToList());
- }
- @model IEnumerable<WebApplication1.Models.Student>
- <br />
- <br/>
- @using (Html.BeginForm("Index", "Home", FormMethod.Get))
- {
- @Html.TextBox("Searching")<input type="submit" value="Search"/>
- }
- <table class="table table-striped">
- <thead>
- <tr>
- <th>Student Id</th>
- <th>Student Name</th>
- <th>Gender</th>
- <th>Class</th>
- <th>Contact</th>
- <th>BloodGroup</th>
- <th>Address</th>
- </tr>
- </thead>
- <tbody>
- @if(Model.Count()==0)
- {
- <tr>
- <td colspan="3" style="color:red">No match Found</td>
- </tr>
- }
- else
- {
- foreach (var item in Model)
- {
- <tr>
- <td>@item.StudentID</td>
- <td>@item.StudentName</td>
- <td>@item.Gender</td>
- <td>@item.Class</td>
- <td>@item.Contact</td>
- <td>@item.BloodGroup</td>
- <td>@item.Address</td>
- </tr>
- }
- }
- </tbody>
- </table>
Add Comment
Please, Sign In to add comment