asp.net mvc - Model Binding to view in MVC -
asp.net mvc - Model Binding to view in MVC -
i beginner mvc , know how can set binded model vaule viewing. here example.
public class datatypes { public guid itemid { get; set; } [required()] public string name { get; set; } [required()] public string status { get; set; } [required()] public datamodel datamodel { get; set; } // binding } public class datamodel { public string activity { get; set; } public datetime ?datetime { get; set; } }
with above model class, sucessfully able bind info ui backend problem how can retrun same info ui using above. tried below code when comes setting vaules binded class (datamodel)
this.datatype.itemid = // guid stored vaule in database this.datatype.name = // name stored vaule in database this.datatype.status = // status stored vaule in database // set activity ui - error.....!!!!!! // error nullreferenceexception unhandled this.datatype.datamodel.activity = // activity stored vaule in database this.datatype.datamodel.datetime = // datetime stored vaule in database homecoming view(this.datatype);
any work around above issue?
advance thanks, hv
it appears forgot instantiate this.datatype.datamodel:
this.datatype.datamodel = new datamodel(); this.datatype.datamodel.activity = // activity stored vaule in database this.datatype.datamodel.datetime
asp.net-mvc model-view-controller asp.net-mvc-2
Comments
Post a Comment