PDA

View Full Version : [CLOSED] Fill controls from controller with model binding



matrixwebtech
Jun 21, 2014, 9:17 PM
I dont know surely,I am correct or wrong

VIEW CODE


X.TextFieldFor(obj=>obj.State).AnchorHorizontal("100%")
.AllowBlank(false).LabelAlign(LabelAlign.Top).Widt h(250),
X.DisplayField().Flex(1).Html(" "),
X.TextFieldFor(obj=>obj.PinCode).AnchorHorizontal("100%")
.AllowBlank(false).LabelAlign(LabelAlign.Top).Widt h(250)

I have some controls like these and bind with model.

CONTROLLER CODE



public ActionResult Edit(string selected)
{
SelectedRowCollection src = JSON.Deserialize<SelectedRowCollection>(selected);
Int64 lRecordID = 0;
foreach (SelectedRow row in src)
{
lRecordID = Convert.ToInt64(row.RecordID);

}
tbl_PM_ProjectInformation _tbl_PM_ProjectInformation = new tbl_PM_ProjectInformation();
_tbl_PM_ProjectInformation.ProjectID = lRecordID;
_tbl_PM_ProjectInformation = _ProjectInformation.pm_projectinformation_GetByPro jectID(_tbl_PM_ProjectInformation);

//X.GetCmp<Hidden>("hdfProjectID").SetValue(Convert.ToInt64(_tbl_PM_ProjectInformat ion.ProjectID).ToString());
//X.GetCmp<TextField>("txtUOMName").Text = _tbl_Pur_MasterUOM.UOMName;
//X.GetCmp<TextField>("txtUOMType").Text = _tbl_Pur_MasterUOM.UOMType;
//X.GetCmp<TextField>("txtDescription").Text = _tbl_Pur_MasterUOM.Description;

X.GetCmp<Window>("Window1").Show();


return this.Direct(_tbl_PM_ProjectInformation);
}

tbl_PM_ProjectInformation is my model,here i fill object of tbl_PM_ProjectInformation and return with Direct.

Is there any way to fill controls in view from controller using this technique.please let me know ,its very helpful for me

Daniil
Jun 23, 2014, 9:52 AM
Hi @matrixwebtech,

So, just to clarify - would you like this

return this.Direct(_tbl_PM_ProjectInformation);
to cause retrieving the values from _tbl_PM_ProjectInformation Model and applying to the fields on client?

I am afraid, there is no such the functionality.

I think I would try to organize the things in the following way. Place all the fields associated to the Model into a partial view. If the Model is changed, then reload the partial view with that new Model.