ASP.NET MVC, Bootstrap Tables, get values for each column

前端 未结 3 1172
说谎
说谎 2021-01-28 13:33

In ASP.NET MVC, I\'ve an action which takes user input about rows and columns and then it navigates to the action which generates required number of rows and columns based on th

3条回答
  •  不要未来只要你来
    2021-01-28 13:53

    to get value horizontally you have to put name attribute in your view like
    
        @{
        foreach (var item in Model.t1_List)
        {
            
        }
        }
    
    Name Allocation Percentage Allocation
    @item.Name
    and then at the time of post or in action method you can get this as Dictionary _d_amt = new Dictionary(); Dictionary _d_per = new Dictionary(); foreach (var key in _frm.AllKeys) { if (key.ParseString().Contains("t1_txtamt-")) { decimal _val = _frm[key].ParseString().ParseDecimal(); decimal _id = key.Replace("t1_txtamt-", "").ParseString().ParseDecimal(); _d_amt.Add(_id, _val); } else if (key.ParseString().Contains("t1_txtper-")) { decimal _val = _frm[key].ParseString().ParseDecimal(); decimal _id = key.Replace("t1_txtper-", "").ParseString().ParseDecimal(); _d_per.Add(_id, _val); } } foreach (var item in _model.t1_List) { AllocationClass _litem = new AllocationClass(); _litem.BId = item.BId; _litem.Name = item.Name; _litem.AllocationPercentage = (from p in _d_per where p.Key == item.BId select p.Value).FirstOrDefault().ParseDecimal(); _litem.AllocationAmount = (from p in _d_amt where p.Key == item.BId select p.Value).FirstOrDefault().ParseDecimal(); _list.Add(_litem); }

提交回复
热议问题