|
|
|
start date: Mon, 7 May 2007 13:36:08 -0500,
posted on: microsoft.public.dotnet.framework.aspnet.datagridcontrol
back
| Thread Index |
|
1
Ross Culver
|
|
2
Ross Culver
|
|
3
Alvin Bruney [MVP] some guy without an email address
|
|
4
Ross Culver
|
|
5
Alvin Bruney [MVP] some guy without an email address
|
|
6
Ross Culver
|
Key in Dictionary
This error message "Item has already been added. Key in dictionary . . . "
has become a major problem for me.
I have a website whose main attractions (the money maker) are the two
datagridviews used to return user requested information. The site is still
in debug mode as we're in the final testing phase, so we're pounding the
query and the grid to test it thoroughly.
This site was built with VS 2K5, DotNet 2.0 on a Windows 2003 server and is
AJAX enabled.
This error is now popping up frequently and can only be corrected by
removing the datakeyNames from the settings, saving and then re-inputting
the keys. The Datamember is set to 'DefaultView'. I have no custom
dictionaries and no code to manage these keys (neither to add nor to remove
keys). Googling the error I found many folks suffering from the problem,
but no one had even mentioned simply removing the keys.
My site is 'DOWN' if I cannot get this problem resolved.
What can I do to stop getting this error? Do I have to manage the keys?
How?
Thanks tremendously in advance.
Ross
Date:Mon, 7 May 2007 13:36:08 -0500
Author:
|
Re: Key in Dictionary
Could this possibly be a session issue? Are the key values dropped at the
end of each session?
Ross
"Ross Culver" wrote in message
news:uvX6mZNkHHA.2008@TK2MSFTNGP05.phx.gbl...
> This error message "Item has already been added. Key in dictionary . . .
> " has become a major problem for me.
>
> I have a website whose main attractions (the money maker) are the two
> datagridviews used to return user requested information. The site is
> still in debug mode as we're in the final testing phase, so we're pounding
> the query and the grid to test it thoroughly.
>
> This site was built with VS 2K5, DotNet 2.0 on a Windows 2003 server and
> is AJAX enabled.
>
> This error is now popping up frequently and can only be corrected by
> removing the datakeyNames from the settings, saving and then re-inputting
> the keys. The Datamember is set to 'DefaultView'. I have no custom
> dictionaries and no code to manage these keys (neither to add nor to
> remove keys). Googling the error I found many folks suffering from the
> problem, but no one had even mentioned simply removing the keys.
>
> My site is 'DOWN' if I cannot get this problem resolved.
>
> What can I do to stop getting this error? Do I have to manage the keys?
> How?
>
> Thanks tremendously in advance.
>
> Ross
>
Date:Mon, 7 May 2007 15:05:19 -0500
Author:
|
Re: Key in Dictionary
I'm not sure i understand your issue. Keys must be unique, the constraints
are enforced. It seems obvious to me that you have a dupe in the process
either with the submit or elsewhere. Are you saying that the data structure
itself is corrupted?
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Ross Culver" wrote in message
news:%23c0PaLOkHHA.4936@TK2MSFTNGP03.phx.gbl...
> Could this possibly be a session issue? Are the key values dropped at the
> end of each session?
>
> Ross
>
>
> "Ross Culver" wrote in message
> news:uvX6mZNkHHA.2008@TK2MSFTNGP05.phx.gbl...
>> This error message "Item has already been added. Key in dictionary . . .
>> " has become a major problem for me.
>>
>> I have a website whose main attractions (the money maker) are the two
>> datagridviews used to return user requested information. The site is
>> still in debug mode as we're in the final testing phase, so we're
>> pounding the query and the grid to test it thoroughly.
>>
>> This site was built with VS 2K5, DotNet 2.0 on a Windows 2003 server and
>> is AJAX enabled.
>>
>> This error is now popping up frequently and can only be corrected by
>> removing the datakeyNames from the settings, saving and then re-inputting
>> the keys. The Datamember is set to 'DefaultView'. I have no custom
>> dictionaries and no code to manage these keys (neither to add nor to
>> remove keys). Googling the error I found many folks suffering from the
>> problem, but no one had even mentioned simply removing the keys.
>>
>> My site is 'DOWN' if I cannot get this problem resolved.
>>
>> What can I do to stop getting this error? Do I have to manage the keys?
>> How?
>>
>> Thanks tremendously in advance.
>>
>> Ross
>>
>
>
Date:Mon, 7 May 2007 19:18:18 -0400
Author:
|
Re: Key in Dictionary
Thanks for responding Alvin, and frankly, as prolific as this error is, I can't understand why everyone is jumping up and down screaming foul.
Ok, the dataviewgrid use and SQLDatasource. There are absolutely no duplicate primary indexes and the primary index is the first of 3 datakeynames specified. The only reason I'm even using these datakeys is because I don't want to display these three columns in the grid, but their data is crucial. The columns corresponding to these 3 datakeys are not necessarily the 1st 3 columns of the grid, if that matters.
I have a select button which when clicked uses the datakey of ID (Select Case Me.gvQuickSearch.SelectedDataKey.Item(1).ToString . . . ) to redirect the user to a page which retrieves pertinent data based on the ID passed in the querystring.
When selected the first time, it works fine. Upon returning to the datagridview page and clicking another (or the same) row, the error occurs without fail, 'Item has already been added. Key in dictionary:'ID' Key being added 'ID'.
As I write this it's clear that it's a session issue. I'm using SQLServer statemode, Autodetect. Apparently when I click the select button, the dictionary is getting repopulated with the datakeys from the grid and since the returned dataset hasn't changed, it's trying to write the same values again. Ok, do I have the wrong session state settings? I've tried switching the session state modes with no change.
Is it possible to clear the dictionary after each row selection?
I'm going to try clearing all session variables on each click and see what happens.
Ross
..
"Alvin Bruney [MVP]" <some guy without an email address> wrote in message news:usm3L4PkHHA.1220@TK2MSFTNGP03.phx.gbl...
> I'm not sure i understand your issue. Keys must be unique, the constraints
> are enforced. It seems obvious to me that you have a dupe in the process
> either with the submit or elsewhere. Are you saying that the data structure
> itself is corrupted?
>
> --
> Regards,
> Alvin Bruney
> ------------------------------------------------------
> Shameless author plug
> Excel Services for .NET is coming...
> OWC Black book on Amazon and
> www.lulu.com/owc
> Professional VSTO 2005 - Wrox/Wiley
>
>
> "Ross Culver" wrote in message
> news:%23c0PaLOkHHA.4936@TK2MSFTNGP03.phx.gbl...
>> Could this possibly be a session issue? Are the key values dropped at the
>> end of each session?
>>
>> Ross
>>
>>
>> "Ross Culver" wrote in message
>> news:uvX6mZNkHHA.2008@TK2MSFTNGP05.phx.gbl...
>>> This error message "Item has already been added. Key in dictionary .. . .
>>> " has become a major problem for me.
>>>
>>> I have a website whose main attractions (the money maker) are the two
>>> datagridviews used to return user requested information. The site is
>>> still in debug mode as we're in the final testing phase, so we're
>>> pounding the query and the grid to test it thoroughly.
>>>
>>> This site was built with VS 2K5, DotNet 2.0 on a Windows 2003 server and
>>> is AJAX enabled.
>>>
>>> This error is now popping up frequently and can only be corrected by >>> removing the datakeyNames from the settings, saving and then re-inputting
>>> the keys. The Datamember is set to 'DefaultView'. I have no custom >>> dictionaries and no code to manage these keys (neither to add nor to >>> remove keys). Googling the error I found many folks suffering from the
>>> problem, but no one had even mentioned simply removing the keys.
>>>
>>> My site is 'DOWN' if I cannot get this problem resolved.
>>>
>>> What can I do to stop getting this error? Do I have to manage the keys?
>>> How?
>>>
>>> Thanks tremendously in advance.
>>>
>>> Ross
>>>
>>
>>
>
>
Date:Mon, 7 May 2007 19:31:00 -0500
Author:
|
Re: Key in Dictionary
perhaps a simple test like:
if(dupe in dictionary)
throw new exception (" I have a dupe");
should indicate where the problem is. If you have an exception, it will tell you clearly that the key duplication was attempted - that's programmer error. If you don't have an exception and you get the *reproducible* error, that's a framework error. And the very thought of that gets me excited so post some code if it's the latter and we will take a look.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Ross Culver" wrote in message news:urLI2fQkHHA.4040@TK2MSFTNGP03.phx.gbl...
Thanks for responding Alvin, and frankly, as prolific as this error is, I can't understand why everyone is jumping up and down screaming foul.
Ok, the dataviewgrid use and SQLDatasource. There are absolutely no duplicate primary indexes and the primary index is the first of 3 datakeynames specified. The only reason I'm even using these datakeys is because I don't want to display these three columns in the grid, but their data is crucial. The columns corresponding to these 3 datakeys are not necessarily the 1st 3 columns of the grid, if that matters.
I have a select button which when clicked uses the datakey of ID (Select Case Me.gvQuickSearch.SelectedDataKey.Item(1).ToString . . . ) to redirect the user to a page which retrieves pertinent data based on the ID passed in the querystring.
When selected the first time, it works fine. Upon returning to the datagridview page and clicking another (or the same) row, the error occurs without fail, 'Item has already been added. Key in dictionary:'ID' Key being added 'ID'.
As I write this it's clear that it's a session issue. I'm using SQLServer statemode, Autodetect. Apparently when I click the select button, the dictionary is getting repopulated with the datakeys from the grid and since the returned dataset hasn't changed, it's trying to write the same values again. Ok, do I have the wrong session state settings? I've tried switching the session state modes with no change.
Is it possible to clear the dictionary after each row selection?
I'm going to try clearing all session variables on each click and see what happens.
Ross
.
"Alvin Bruney [MVP]" <some guy without an email address> wrote in message news:usm3L4PkHHA.1220@TK2MSFTNGP03.phx.gbl...
> I'm not sure i understand your issue. Keys must be unique, the constraints
> are enforced. It seems obvious to me that you have a dupe in the process
> either with the submit or elsewhere. Are you saying that the data structure
> itself is corrupted?
>
> --
> Regards,
> Alvin Bruney
> ------------------------------------------------------
> Shameless author plug
> Excel Services for .NET is coming...
> OWC Black book on Amazon and
> www.lulu.com/owc
> Professional VSTO 2005 - Wrox/Wiley
>
>
> "Ross Culver" wrote in message
> news:%23c0PaLOkHHA.4936@TK2MSFTNGP03.phx.gbl...
>> Could this possibly be a session issue? Are the key values dropped at the
>> end of each session?
>>
>> Ross
>>
>>
>> "Ross Culver" wrote in message
>> news:uvX6mZNkHHA.2008@TK2MSFTNGP05.phx.gbl...
>>> This error message "Item has already been added. Key in dictionary . . .
>>> " has become a major problem for me.
>>>
>>> I have a website whose main attractions (the money maker) are the two
>>> datagridviews used to return user requested information. The site is
>>> still in debug mode as we're in the final testing phase, so we're
>>> pounding the query and the grid to test it thoroughly.
>>>
>>> This site was built with VS 2K5, DotNet 2.0 on a Windows 2003 server and
>>> is AJAX enabled.
>>>
>>> This error is now popping up frequently and can only be corrected by
>>> removing the datakeyNames from the settings, saving and then re-inputting
>>> the keys. The Datamember is set to 'DefaultView'. I have no custom
>>> dictionaries and no code to manage these keys (neither to add nor to
>>> remove keys). Googling the error I found many folks suffering from the
>>> problem, but no one had even mentioned simply removing the keys.
>>>
>>> My site is 'DOWN' if I cannot get this problem resolved.
>>>
>>> What can I do to stop getting this error? Do I have to manage the keys?
>>> How?
>>>
>>> Thanks tremendously in advance.
>>>
>>> Ross
>>>
>>
>>
>
>
Date:Tue, 8 May 2007 19:42:20 -0400
Author:
|
Re: Key in Dictionary
Alvin,
I'll have to thorough research this at a later date. The urgency to get the site working outweighed finding the root cause.
Having said that, I actually think I do know the cause and it's my lack of formal training. Correct me if I'm wrong (and slap me if I'm stupid), but here goes.
Let's say I've set my grid to 10 rows. Everytime the grid binds the datakeys for those 10 rows are stored in session in the dictionary. Change pages, the new set of datakeys are stored. My fundamental mistake was that I wanted to create a set of session variables when the user first loads the site and I wanted those variables to be maintained, not removed and re-added, as the user made choices and navigated back and forth through the site. To get around this issue (and maybe someone can tell me a more surgical way to accomplish this) I had to removeall session variable just before databinding the grid. Unfortunately for me, that meant that I had to capture to hiddenfields the variable values and then session.add back in the variables when redirecting to another page.
I did a session.count and only my explicit session variables were present, not this dictionary. So I couldn't just clear the dictionary as I would have liked.
That's what I've found. Thanks again for the assistance.
Ross
"Alvin Bruney [MVP]" <some guy without an email address> wrote in message news:OU%238SqckHHA.4040@TK2MSFTNGP03.phx.gbl...
perhaps a simple test like:
if(dupe in dictionary)
throw new exception (" I have a dupe");
should indicate where the problem is. If you have an exception, it will tell you clearly that the key duplication was attempted - that's programmer error. If you don't have an exception and you get the *reproducible* error, that's a framework error. And the very thought of that gets me excited so post some code if it's the latter and we will take a look.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Ross Culver" wrote in message news:urLI2fQkHHA.4040@TK2MSFTNGP03.phx.gbl...
Thanks for responding Alvin, and frankly, as prolific as this error is, I can't understand why everyone is jumping up and down screaming foul.
Ok, the dataviewgrid use and SQLDatasource. There are absolutely no duplicate primary indexes and the primary index is the first of 3 datakeynames specified. The only reason I'm even using these datakeys is because I don't want to display these three columns in the grid, but their data is crucial. The columns corresponding to these 3 datakeys are not necessarily the 1st 3 columns of the grid, if that matters.
I have a select button which when clicked uses the datakey of ID (Select Case Me.gvQuickSearch.SelectedDataKey.Item(1).ToString . . . ) to redirect the user to a page which retrieves pertinent data based on the ID passed in the querystring.
When selected the first time, it works fine. Upon returning to the datagridview page and clicking another (or the same) row, the error occurs without fail, 'Item has already been added. Key in dictionary:'ID' Key being added 'ID'.
As I write this it's clear that it's a session issue. I'm using SQLServer statemode, Autodetect. Apparently when I click the select button, the dictionary is getting repopulated with the datakeys from the grid and since the returned dataset hasn't changed, it's trying to write the same values again. Ok, do I have the wrong session state settings? I've tried switching the session state modes with no change.
Is it possible to clear the dictionary after each row selection?
I'm going to try clearing all session variables on each click and see what happens.
Ross
.
"Alvin Bruney [MVP]" <some guy without an email address> wrote in message news:usm3L4PkHHA.1220@TK2MSFTNGP03.phx.gbl...
> I'm not sure i understand your issue. Keys must be unique, the constraints
> are enforced. It seems obvious to me that you have a dupe in the process
> either with the submit or elsewhere. Are you saying that the data structure
> itself is corrupted?
>
> --
> Regards,
> Alvin Bruney
> ------------------------------------------------------
> Shameless author plug
> Excel Services for .NET is coming...
> OWC Black book on Amazon and
> www.lulu.com/owc
> Professional VSTO 2005 - Wrox/Wiley
>
>
> "Ross Culver" wrote in message
> news:%23c0PaLOkHHA.4936@TK2MSFTNGP03.phx.gbl...
>> Could this possibly be a session issue? Are the key values dropped at the
>> end of each session?
>>
>> Ross
>>
>>
>> "Ross Culver" wrote in message
>> news:uvX6mZNkHHA.2008@TK2MSFTNGP05.phx.gbl...
>>> This error message "Item has already been added. Key in dictionary . . .
>>> " has become a major problem for me.
>>>
>>> I have a website whose main attractions (the money maker) are the two
>>> datagridviews used to return user requested information. The site is
>>> still in debug mode as we're in the final testing phase, so we're
>>> pounding the query and the grid to test it thoroughly.
>>>
>>> This site was built with VS 2K5, DotNet 2.0 on a Windows 2003 server and
>>> is AJAX enabled.
>>>
>>> This error is now popping up frequently and can only be corrected by
>>> removing the datakeyNames from the settings, saving and then re-inputting
>>> the keys. The Datamember is set to 'DefaultView'. I have no custom
>>> dictionaries and no code to manage these keys (neither to add nor to
>>> remove keys). Googling the error I found many folks suffering from the
>>> problem, but no one had even mentioned simply removing the keys.
>>>
>>> My site is 'DOWN' if I cannot get this problem resolved.
>>>
>>> What can I do to stop getting this error? Do I have to manage the keys?
>>> How?
>>>
>>> Thanks tremendously in advance.
>>>
>>> Ross
>>>
>>
>>
>
>
Date:Wed, 9 May 2007 08:34:39 -0500
Author:
|
|
|