This is a migrated thread and some comments may be shown as answers.

[Solved] Wrong edit model on insert

1 Answer 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mattias
Top achievements
Rank 1
Mattias asked on 01 Nov 2011, 07:10 PM
Hi,
I'm getting:
The model item passed into the dictionary is of type 'Swh.Vwb.ViewModels.Admin.CountryEditViewModel', but this dictionary requires a model item of type 'Swh.Vwb.ViewModels.Admin.CountryDisplayViewModel'.

when adding new rows in my grid. Updating a row works fine!

@model Swh.Vwb.ViewModels.Admin.CountryDisplayViewModel
...
@{Html.Telerik()
    .Grid(Model.Countries)
    .Name("Countries")
    .DataKeys(dataKeys => dataKeys.Add(x => x.ID))
    .EnableCustomBinding(true)
    .PrefixUrlParameters(false)
    .ToolBar(commands => commands.Insert())
    .DataBinding(dataBinding =>
    {
        dataBinding.Server()
            .Select("countries", "store")
            .Insert("insertcountry", "store")
            .Update("updatecountry", "store")
 
...
public ActionResult InsertCountry(CountryEditViewModel model)
{
 
...
 
public ActionResult UpdateCountry(CountryEditViewModel model)
{
 
...

The model binded to the grid is of type: IList<CountryEditViewModel>.
Why am I getting this error?

Regards,
Mattias


1 Answer, 1 is accepted

Sort by
0
Mattias
Top achievements
Rank 1
answered on 01 Nov 2011, 07:16 PM
Never mind, just me who had wrong model on return in the insert method.
Tags
Grid
Asked by
Mattias
Top achievements
Rank 1
Answers by
Mattias
Top achievements
Rank 1
Share this question
or