[CLOSED] Fill controls from controller with model binding

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Fill controls from controller with model binding

    I dont know surely,I am correct or wrong

    VIEW CODE
     X.TextFieldFor(obj=>obj.State).AnchorHorizontal("100%")
                                                .AllowBlank(false).LabelAlign(LabelAlign.Top).Width(250),
                                                X.DisplayField().Flex(1).Html(" "),
                                                X.TextFieldFor(obj=>obj.PinCode).AnchorHorizontal("100%")
                                                .AllowBlank(false).LabelAlign(LabelAlign.Top).Width(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_GetByProjectID(_tbl_PM_ProjectInformation);
    
                //X.GetCmp<Hidden>("hdfProjectID").SetValue(Convert.ToInt64(_tbl_PM_ProjectInformation.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
    Last edited by Daniil; Jun 27, 2014 at 10:55 AM. Reason: [CLOSED]
  2. #2
    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.

Similar Threads

  1. Form binding to the model
    By errno in forum 2.x Help
    Replies: 7
    Last Post: May 24, 2013, 5:34 AM
  2. Replies: 1
    Last Post: Mar 22, 2013, 2:47 AM
  3. Replies: 1
    Last Post: Oct 05, 2012, 1:36 PM
  4. [CLOSED] MVC, Binding model to Store
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 08, 2011, 3:19 PM
  5. binding checkbox selection model
    By VipulTyagi in forum 1.x Help
    Replies: 2
    Last Post: Apr 07, 2011, 11:36 AM

Posting Permissions