We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Nested template value is not deserialized into object property

Thread ID:

Created:

Updated:

Platform:

Replies:

113900 Oct 16,2013 04:13 AM UTC Oct 23,2013 04:36 AM UTC ASP.NET MVC (Classic) 2
loading
Tags: Grid
Jeremy Branham
Asked On October 16, 2013 04:13 AM UTC

I am using a generic template inside the dialog for editing the grid row item.
it looks like this -
 
@using (Html.BeginForm()){
    @Html.EditorForModel()
}
 
 
My model has a Editor Template that looks like this -
 
<fieldset>
    <legend>Environment</legend>
    <div>@Html.EditorFor(m=>m.Id)</div>
    <div>
        <div>
            @Html.LabelFor(m=>m.Name)
        </div>
        <div>
            @Html.EditorFor(m=>m.Name)
        </div>
    </div>
        <div>
        <div>
            @Html.LabelFor(m=>m.AccountId)
        </div>
        <div>
            @Html.EditorFor(m=>m.AccountId)
        </div>
    </div>   
    <div>
        <div>
            @Html.LabelFor(m=>m.ContactId)
        </div>
        <div>
            @Html.EditorFor(m=>m.ContactId)
        </div>
    </div>   
    <div>
        <div>
            @Html.LabelFor(m=>m.ExternalId)
        </div>
        <div>
            @Html.EditorFor(m=>m.ExternalId)
        </div>
    </div>   
</fieldset>

 

And the AccountId inside that template has an EditorTemplate that looks like this -

@Html.DropDownList("Account", new SelectList(MyClass.GetAccounts(), "Id", "Name", Model), new { id = "AccountId", name = "AccountId" })

You can see that I added the html attributes "id" and "name".

The problem I am having, is that form values are not being added to the object when it's deserialized. The "name" attribute looks like AccountId.Account and the "id" attribute looks like AccountId.AccountId.
I added the html attributes to try matching the correct values manually, but the "name" attribute doesn't stick.

Is this a bug?


Jeremy Branham
Replied On October 19, 2013 05:10 PM UTC

I realized this is default MVC behavior. To change this, I would need to build a custom model binder.
I'll just copy/paste view configurations for now.

Shanmugaraja K [Syncfusion]
Replied On October 23, 2013 04:36 AM UTC

Hi  Jeremy,

Thanks for your update.

we will wait to hear from you.

Please let me know if you need further assistance.

Regards,
Shanmugaraja K

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;