asp.net mvc - Add Data to a model -
i have created model list in it
namespace omiv2._1kswilson.models { public class legendclassvm { public list <string> legendvalues { get; set; } } }
then have foreach loop creates strings want use.
list<string> values = new list<string>(); foreach (feature f in allfeatures) { if (f.columnvalues.containskey(layercode)) { if (!values.contains(f.columnvalues[layercode].tostring())) { values.add(f.columnvalues[layercode].tostring()); } } }
how add together these items model list. code executes 5 times need store alot of data.
any suggestions appreciated
try this
public actionresult index() { legendclassvm model = new legendclassvm(); model.legendvalues = new list <string>(); foreach (feature f in allfeatures) { if (f.columnvalues.containskey(layercode)) { if (!values.contains(f.columnvalues[layercode].tostring())) { model.legendvalues.add(f.columnvalues[layercode].tostring()); } } } homecoming view(model); }
asp.net-mvc asp.net-mvc-4 model-view-controller
No comments:
Post a Comment