cannot delete or edit inserted records ( via detailsview) in gridview

Discussion in 'ASP .Net Web Controls' started by Marc, Jul 31, 2006.

  1. Marc

    Marc Guest

    Hi,

    I made a detailsview for inserting records.
    I also made a gridview for editing and deleting the same records.
    The keyfield is an autonumbering field in Access (pcnr).

    My problem is: I can see the new inserted records in the gridview but I
    can't delete or edit them. When clicking on delete or edit link, nothing
    happens (no error either). All the others records (not inserted via the
    detailsview) can be edited and deleted.

    Thanks for help
    Marc

    Here part of my code with the gridview:
    ---------------------------------------
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConflictDetection="CompareAllValues"
    ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydb"
    DeleteCommand="DELETE FROM [pc] WHERE [pcnr] = ? AND [naam] = ? AND
    [defect] = ? AND [type] = ? AND [software] = ? AND [lokaal] = ?"
    InsertCommand="INSERT INTO [pc] ([pcnr], [naam], [defect], [type],
    [software], [lokaal]) VALUES (?, ?, ?, ?, ?, ?)"
    OldValuesParameterFormatString="original_{0}"
    ProviderName="System.Data.OleDb"
    SelectCommand="SELECT * FROM [pc]" UpdateCommand="UPDATE [pc] SET [naam]
    = ?, [defect] = ?, [type] = ?, [software] = ?, [lokaal] = ? WHERE [pcnr] = ?
    AND [naam] = ? AND [defect] = ? AND [type] = ? AND [software] = ? AND
    [lokaal] = ?">
    <DeleteParameters>
    <asp:parameter Name="original_pcnr" Type="Int32" />
    <asp:parameter Name="original_naam" Type="String" />
    <asp:parameter Name="original_defect" Type="Boolean" />
    <asp:parameter Name="original_type" Type="String" />
    <asp:parameter Name="original_software" Type="String" />
    <asp:parameter Name="original_lokaal" Type="String" />
    </DeleteParameters>
    <UpdateParameters>
    <asp:parameter Name="naam" Type="String" />
    <asp:parameter Name="defect" Type="Boolean" />
    <asp:parameter Name="type" Type="String" />
    <asp:parameter Name="software" Type="String" />
    <asp:parameter Name="lokaal" Type="String" />
    <asp:parameter Name="original_pcnr" Type="Int32" />
    <asp:parameter Name="original_naam" Type="String" />
    <asp:parameter Name="original_defect" Type="Boolean" />
    <asp:parameter Name="original_type" Type="String" />
    <asp:parameter Name="original_software" Type="String" />
    <asp:parameter Name="original_lokaal" Type="String" />
    </UpdateParameters>
    </asp:SqlDataSource>

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
    AllowSorting="True" PageSize="14" width="990px"
    AutoGenerateColumns="False" CellPadding="4" DataKeyNames="pcnr"
    DataSourceID="SqlDataSource1"
    ForeColor="#333333" GridLines="None">
    <Columns>
    <asp:CommandField ShowEditButton="True" />
    <asp:TemplateField>
    <ItemTemplate>
    <asp:LinkButton ID="lb1" runat="server"
    OnClientClick="return confirm(yes?');"
    CommandName="Delete">
    </asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="pcnr" HeaderText="pcnr"
    InsertVisible="False" ReadOnly="True"
    SortExpression="pcnr" />
    <asp:BoundField DataField="naam" HeaderText="naam"
    SortExpression="naam" />
    <asp:CheckBoxField DataField="defect" HeaderText="defect"
    SortExpression="defect" />
    <asp:BoundField DataField="type" HeaderText="type"
    SortExpression="type" />
    <asp:BoundField DataField="software" HeaderText="software"
    SortExpression="software" />
    <asp:BoundField DataField="lokaal" HeaderText="lokaal"
    SortExpression="lokaal" />
    </Columns>
    </asp:GridView>
    Marc, Jul 31, 2006
    #1
    1. Advertising

  2. Marc

    Marc Guest

    I found it.
    All the fields must be filled ..


    "Marc" <> schreef in bericht
    news:%...
    > Hi,
    >
    > I made a detailsview for inserting records.
    > I also made a gridview for editing and deleting the same records.
    > The keyfield is an autonumbering field in Access (pcnr).
    >
    > My problem is: I can see the new inserted records in the gridview but I
    > can't delete or edit them. When clicking on delete or edit link, nothing
    > happens (no error either). All the others records (not inserted via the
    > detailsview) can be edited and deleted.
    >
    > Thanks for help
    > Marc
    >
    > Here part of my code with the gridview:
    > ---------------------------------------
    > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > ConflictDetection="CompareAllValues"
    > ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data
    > Source=C:\mydb"
    > DeleteCommand="DELETE FROM [pc] WHERE [pcnr] = ? AND [naam] = ? AND
    > [defect] = ? AND [type] = ? AND [software] = ? AND [lokaal] = ?"
    > InsertCommand="INSERT INTO [pc] ([pcnr], [naam], [defect], [type],
    > [software], [lokaal]) VALUES (?, ?, ?, ?, ?, ?)"
    > OldValuesParameterFormatString="original_{0}"
    > ProviderName="System.Data.OleDb"
    > SelectCommand="SELECT * FROM [pc]" UpdateCommand="UPDATE [pc] SET [naam]
    > = ?, [defect] = ?, [type] = ?, [software] = ?, [lokaal] = ? WHERE [pcnr] =
    > ? AND [naam] = ? AND [defect] = ? AND [type] = ? AND [software] = ? AND
    > [lokaal] = ?">
    > <DeleteParameters>
    > <asp:parameter Name="original_pcnr" Type="Int32" />
    > <asp:parameter Name="original_naam" Type="String" />
    > <asp:parameter Name="original_defect" Type="Boolean" />
    > <asp:parameter Name="original_type" Type="String" />
    > <asp:parameter Name="original_software" Type="String" />
    > <asp:parameter Name="original_lokaal" Type="String" />
    > </DeleteParameters>
    > <UpdateParameters>
    > <asp:parameter Name="naam" Type="String" />
    > <asp:parameter Name="defect" Type="Boolean" />
    > <asp:parameter Name="type" Type="String" />
    > <asp:parameter Name="software" Type="String" />
    > <asp:parameter Name="lokaal" Type="String" />
    > <asp:parameter Name="original_pcnr" Type="Int32" />
    > <asp:parameter Name="original_naam" Type="String" />
    > <asp:parameter Name="original_defect" Type="Boolean" />
    > <asp:parameter Name="original_type" Type="String" />
    > <asp:parameter Name="original_software" Type="String" />
    > <asp:parameter Name="original_lokaal" Type="String" />
    > </UpdateParameters>
    > </asp:SqlDataSource>
    >
    > <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
    > AllowSorting="True" PageSize="14" width="990px"
    > AutoGenerateColumns="False" CellPadding="4" DataKeyNames="pcnr"
    > DataSourceID="SqlDataSource1"
    > ForeColor="#333333" GridLines="None">
    > <Columns>
    > <asp:CommandField ShowEditButton="True" />
    > <asp:TemplateField>
    > <ItemTemplate>
    > <asp:LinkButton ID="lb1" runat="server"
    > OnClientClick="return confirm(yes?');"
    > CommandName="Delete">
    > </asp:LinkButton>
    > </ItemTemplate>
    > </asp:TemplateField>
    > <asp:BoundField DataField="pcnr" HeaderText="pcnr"
    > InsertVisible="False" ReadOnly="True"
    > SortExpression="pcnr" />
    > <asp:BoundField DataField="naam" HeaderText="naam"
    > SortExpression="naam" />
    > <asp:CheckBoxField DataField="defect" HeaderText="defect"
    > SortExpression="defect" />
    > <asp:BoundField DataField="type" HeaderText="type"
    > SortExpression="type" />
    > <asp:BoundField DataField="software" HeaderText="software"
    > SortExpression="software" />
    > <asp:BoundField DataField="lokaal" HeaderText="lokaal"
    > SortExpression="lokaal" />
    > </Columns>
    > </asp:GridView>
    >
    >
    >
    >
    Marc, Jul 31, 2006
    #2
    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. =?Utf-8?B?a2Vu?=
    Replies:
    1
    Views:
    10,324
    Wiktor Zychla [C# MVP]
    Jan 23, 2006
  2. Marc
    Replies:
    1
    Views:
    3,526
  3. David Lozzi

    edit and Inserted Item in DetailsView

    David Lozzi, Jan 12, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    416
    David Lozzi
    Jan 12, 2007
  4. Replies:
    0
    Views:
    127
  5. Dan

    Delete records or update records

    Dan, May 10, 2004, in forum: ASP General
    Replies:
    1
    Views:
    460
    Ray at
    May 10, 2004
Loading...

Share This Page