Solution for posterity: GridView, Datakeys, and "Item has already been added. Key in dictionary: 'Ca

Discussion in 'ASP .Net' started by Guest, Jul 21, 2006.

  1. Guest

    Guest Guest

    I got stuck today on an annoying problem involving DataKeys, datasources,
    and the GridView: I kept getting errors saying things to the effect of""Item
    has already been added. Key in dictionary: 'Con_ContentID' Key being added:
    'Con_ContentID'""

    I figured I would post the solution I eventually found, because Googling
    around on this revealed a number of puzzled people who had the same problem,
    and few solutions. People kept pointing the puzzled legions to possibilities
    involving manual entries to collections and the like. At least in my case,
    this was not the problem.

    You're most apt to run into this error with bigger, trickier apps involving
    Multiviews, multiple application modes, and custom update methods. You will
    reliably get the error above if you accidentally invoke DataBind() more than
    once in an attempt to refresh the grid. Forcing the update is good, but make
    sure you do it just once. ;)

    -KF
    Guest, Jul 21, 2006
    #1
    1. Advertising

  2. Hi,

    Thank you for sharing your experience with the community.

    If you need more discussion on it, please feel free to post here.

    Have a nice day!


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Jul 21, 2006
    #2
    1. Advertising

  3. Guest

    wwwtar

    Joined:
    Oct 2, 2006
    Messages:
    3
    Help!

    I'm getting the same error noted above (using gridview control). My application involves multiviews. When one record is selected in one view, the page posts back. On postback, i rebuilt the views b/c they are linked to one "master" view. I'm doing a databind the first time the page is loaded, then again on postback. I get the error when i add the dynamically built gridview control to the placeholder. Any hints?
    wwwtar, Nov 2, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. micky
    Replies:
    0
    Views:
    1,396
    micky
    Dec 20, 2005
  2. =?Utf-8?B?Q2hyaXNGcm9obGljaA==?=

    Parser Error Message: The entry 'ConnString1' has already been add

    =?Utf-8?B?Q2hyaXNGcm9obGljaA==?=, Sep 21, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    13,895
    David R. Longnecker
    Sep 21, 2006
  3. Joel Finkel

    DataGrid1.DataKeys[e.Item.ItemIndex] array index out of bounds

    Joel Finkel, Sep 4, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    312
    Joel Finkel
    Sep 4, 2003
  4. Marco Liedekerken

    DataKeyName GridView has already been added

    Marco Liedekerken, Nov 7, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    743
    Marco Liedekerken
    Nov 7, 2006
  5. avital

    Item has already been added. Key in dictionary

    avital, Dec 12, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    513
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Dec 19, 2006
Loading...

Share This Page