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

G

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
 
W

Walter Wang [MSFT]

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 ([email protected], 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.
 
Joined
Oct 2, 2006
Messages
3
Reaction score
0
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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top