M
Marco Liedekerken
Hi,
I get an error which says:
Item has already been added. Key in dictionary: 'MutaP_StartDate' Key
being added: 'MutaP_StartDate'
I have a master page and in its content page I have a usercontrol with
in that 3 usercontrols as tabs.
In one of the 3 user controls I have a GridView defined (see my code
down under). I bind this GridView via DataSourceID to a SqlDataSource
(see my code down under). In my code behind of this user control I have
a method that fills other subcontrols which are on it (the GridView
will automaticly be filled).
My problem is that when I click on a edit button (or do deleting,
sorting ....) of the Gridview I get the error message.
I think it has to do with viewstate or something (I tried a lot of
combinations allready), but I can not put a finger on this problem. It
seems that it tries 2 times to add the DataKey which I put in as
DataKeyNames of the GridView. Maybe this is because of a problem with
databinding ...
Can someone help me with this, because I am puzzled?
Thx, Marco
<asp:GridView ID="GridView1" runat="server"
DataSourceID="SqlDataSourceParameterMutaties"
AutoGenerateEditButton="true" DataKeyNames="MutaP_StartDate"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField HeaderText="StartDatum"
DataField="MutaP_StartDate" ReadOnly="true" />
<asp:BoundField HeaderText="Waarde"
DataField="MutaP_Value" />
<asp:BoundField HeaderText="Omschrijving "
DataField="MutaP_Description" />
<asp:BoundField HeaderText="Gewijzigd"
DataField="MutaP_ChangeTime" ReadOnly="true"/>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceParameterMutaties"
runat="server" ConnectionString="<%$ ConnectionStrings:SSSDemo %>"
SelectCommand="SELECT MutaP_StartDate, MutaP_Value,
MutaP_Description, MutaP_ChangeTime FROM dbo.SSS_TMutaties_parameters
WHERE (MutaP_Varia_ID = @MutaP_Varia_ID) AND (MutaP_Param_ID =
@MutaP_Param_ID) ORDER BY MutaP_StartDate"
UpdateCommand="UPDATE dbo.SSS_TMutaties_parameters SET MutaP_Value
= @MutaP_Value, MutaP_Description = @MutaP_Description,
MutaP_ChangeTime = GETDATE() WHERE (MutaP_Varia_ID = @MutaP_Varia_ID)
AND (MutaP_Param_ID = @MutaP_Param_ID) AND (MutaP_StartDate =
@MutaP_StartDate)" >
<SelectParameters>
<asp:QueryStringParameter
Name="MutaP_Varia_ID"
QueryStringField="VariantID"
Type="Int32" />
<asp:QueryStringParameter
Name="MutaP_Param_ID"
QueryStringField="ParameterID"
Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:QueryStringParameter
Name="MutaP_Varia_ID"
QueryStringField="VariantID"
Type="Int32" />
<asp:QueryStringParameter
Name="MutaP_Param_ID"
QueryStringField="ParameterID"
Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
I get an error which says:
Item has already been added. Key in dictionary: 'MutaP_StartDate' Key
being added: 'MutaP_StartDate'
I have a master page and in its content page I have a usercontrol with
in that 3 usercontrols as tabs.
In one of the 3 user controls I have a GridView defined (see my code
down under). I bind this GridView via DataSourceID to a SqlDataSource
(see my code down under). In my code behind of this user control I have
a method that fills other subcontrols which are on it (the GridView
will automaticly be filled).
My problem is that when I click on a edit button (or do deleting,
sorting ....) of the Gridview I get the error message.
I think it has to do with viewstate or something (I tried a lot of
combinations allready), but I can not put a finger on this problem. It
seems that it tries 2 times to add the DataKey which I put in as
DataKeyNames of the GridView. Maybe this is because of a problem with
databinding ...
Can someone help me with this, because I am puzzled?
Thx, Marco
<asp:GridView ID="GridView1" runat="server"
DataSourceID="SqlDataSourceParameterMutaties"
AutoGenerateEditButton="true" DataKeyNames="MutaP_StartDate"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField HeaderText="StartDatum"
DataField="MutaP_StartDate" ReadOnly="true" />
<asp:BoundField HeaderText="Waarde"
DataField="MutaP_Value" />
<asp:BoundField HeaderText="Omschrijving "
DataField="MutaP_Description" />
<asp:BoundField HeaderText="Gewijzigd"
DataField="MutaP_ChangeTime" ReadOnly="true"/>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceParameterMutaties"
runat="server" ConnectionString="<%$ ConnectionStrings:SSSDemo %>"
SelectCommand="SELECT MutaP_StartDate, MutaP_Value,
MutaP_Description, MutaP_ChangeTime FROM dbo.SSS_TMutaties_parameters
WHERE (MutaP_Varia_ID = @MutaP_Varia_ID) AND (MutaP_Param_ID =
@MutaP_Param_ID) ORDER BY MutaP_StartDate"
UpdateCommand="UPDATE dbo.SSS_TMutaties_parameters SET MutaP_Value
= @MutaP_Value, MutaP_Description = @MutaP_Description,
MutaP_ChangeTime = GETDATE() WHERE (MutaP_Varia_ID = @MutaP_Varia_ID)
AND (MutaP_Param_ID = @MutaP_Param_ID) AND (MutaP_StartDate =
@MutaP_StartDate)" >
<SelectParameters>
<asp:QueryStringParameter
Name="MutaP_Varia_ID"
QueryStringField="VariantID"
Type="Int32" />
<asp:QueryStringParameter
Name="MutaP_Param_ID"
QueryStringField="ParameterID"
Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:QueryStringParameter
Name="MutaP_Varia_ID"
QueryStringField="VariantID"
Type="Int32" />
<asp:QueryStringParameter
Name="MutaP_Param_ID"
QueryStringField="ParameterID"
Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>