c# - MVC - Assigning Values to Dictionary -


i trying add dictionary values in view, following code :-

public class {      public int employeeid { get; set; }      public int employeename { get; set; }       public dictionary<string, double> dic1 { get; set; }      public dictionary<string, double> dic2 { get; set; } } 

view :-

@model list<models.to>   @for (int = 0; < @model.count; i++) {           @html.hiddenfor(m => m[i].employeeid)           @html.hiddenfor(m => m[i].employeename)            ....           @html.hiddenfor(m => m[i].dic1, value = "") // psuedo  } 

as have assigned values employeeid & employeename in post method in controller, how assign values dictionary?

you can't put whole dictionary hidden field. dictionary enumerable, have work out each key/value.

@for (int = 0; < @model.count; i++) {       @html.hiddenfor(m => m[i].employeeid)       @html.hiddenfor(m => m[i].employeename)        ....       foreach (string key in dic1.keys)       {                @html.hiddenfor(m => m[i].dic1[key])       }  } 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -