c# - How to get particular row of data in Strongly typed view in MVC application..? -


my view index.cshtml (strongly typed view class name:busdetails.cs)contains code below:

model ienumerable<mvc_dal.busdetails>  @html.actionlink("create new", "addbus")  <table> <tr>     <th>         @html.displaynamefor(model => model.bussrlno)     </th>     <th>         @html.displaynamefor(model => model.busname)     </th>     <th></th> </tr>  @foreach (var item in model)   {  <tr>     <td>         @html.displayfor(modelite => item.bussrlno)     </td>     <td>         @html.displayfor(modelitem => item.busname)     </td>     <td>         @html.actionlink("edit", "edit", new { id=item.bussrlno }) |         @html.actionlink("details", "details", new { id=item.bussrlno */ })|          @html.actionlink("delete", "delete", new { id=item.bussrlno */ })|      </td>   </tr>  }  </table> 

this works fine results in image below. if want's particular row of data in output,let's 4th rows data busname=kukke other purpose, how can it.?

also busdetails.cs contains code below.

 public class busdetails   {     public int bussrlno { get; set; }     public string busname { get; set; }   } 

enter image description here

you can use elementat(index) so:

busdetails item4 = model.elementat(3); 

and can use data in view this:

<div>4th bus name: @item4.busname</div> <div>4th bus number: @item4.bussrlno</div> 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -