Search code examples
c#asp.netasp.net-mvcwebgrid

How pass list<object> into webgrid


I'm trying to put into webgrid collection

public class MyClass()
{
    List<Row> rows {get; set;}
}

public class Row()
{
    public string code {get; set;}
}

grid.Column("Amount",
format: @<text>
@Html.TextBoxFor(model => model.rows.FirstOrDefault().code, new { @class = "edit-mode", size = 5 })
</text>),

Using model.rows.FirstOrDefault().code it works but returns first element of collection in each row.

model.rows.GetEnumerator().Current.code returns nothing

How to get right desision to get each element of collection in own row


Solution

  • Source:

    Used this format: InputExtensions.TextBox(Html, "Last Name", item.LastName) // static call