dynamic columns in @Html.Grid and editable textbox for each column in a row

1.1k Views Asked by At

I want to bind a Grid which will have unknown number of columns. I have Master Table of Currencies having columns :

(ID NAME) 1 USD 2 GEL 3 MXN 4 EURO 5 PKR logged in user is assigned let say two of those USD and EURO .. now there will be 10 textboxes in the grid 5 rows and 2 columns (2 textboxes in each row) .. problem is it is not binding values to all textboxes but just some of them.. any help will be appreciated.

    public class ConversionRates
    {
       public string ParentCurrencyName {get;set;}
       public int ParentCurrencyID {get;set;}
       public List<SettlementValues> Values{get;set;}
    }
    public class SettlementValues
    {
       public string ChildCurrencyName {get;set;}
       public string ChildCurrencyID {get;set;}
       public decimal Value {get;set;}
    }

View

    @Html.Grid(Model).Columns(columns =>{
    columns.Add(model => model.ParentCurrencyName).Titled("Parent   Currency").Filterable(true);
    foreach(var item in Model.Values)
    {

       columns.Add(model => item.ChildCurrencyName);

       <input type="text" name="Value" value="@item.Value">
    }
     }).WithPaging(3).Sortable(true)
0

There are 0 best solutions below