An item with the same key has already been added.

2 posts, 0 answers
  1. Gavin
    Gavin avatar
    3 posts
    Member since:
    Jun 2016

    Posted 22 Jun 2016 Link to this post

    Hi, I have seen this error in a number of threads on the forum, none of which seem to be caused by the same thing as I am trying. 


    All it amounts to is using the same 'Id' column in the expressions for both a custom command routing value and the datasource server() model id mapping. I dont really understand why using the id in these two places should cause this problem?


                    .Columns(columns =>
                        columns.Command(commands => commands.Custom("View").Action("Index", "Detail")
                            .DataRouteValues(rv => rv.Add(m => m.Id)));
                        columns.Bound(m => m.Heading);
                    .DataSource(ds => ds.Server().Model(model => model.Id(m => m.Id)))

    If this is a bug, is there a work around I can use?




  2. Konstantin Dikov
    Konstantin Dikov avatar
    2466 posts

    Posted 24 Jun 2016 Link to this post

    Hello Gavin,

    The Id field from the model will be automatically passed as parameter for the custom command, so that is why you are receiving the error message. You can safely remove that field from the DataRouteValues and you will still be to retrieve it.

    Hope this helps.

    Konstantin Dikov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top