DataKeyName GridView has already been added

Discussion in 'ASP .Net Datagrid Control' started by Marco Liedekerken, Nov 7, 2006.

  1. 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>
    Marco Liedekerken, Nov 7, 2006
    #1
    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,397
    micky
    Dec 20, 2005
  2. Guest
    Replies:
    2
    Views:
    5,562
    wwwtar
    Nov 2, 2006
  3. =?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,897
    David R. Longnecker
    Sep 21, 2006
  4. Replies:
    1
    Views:
    17,935
  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