ASP.NET Gridview - Edit (Update)

Discussion in 'ASP .Net Web Controls' started by bgreer5050@yahoo.com, Aug 29, 2007.

  1. Guest

    When I try and update using the gridview edit option, all of the
    records in the entire Access database
    get changed. Is this normal in gridview? Is there a way to change
    this behavior? Or should I
    be using a different control?

    Thanks

    Page Code is as follows:

    <%@ Page Language="VB" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
    www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Search Parts By Mfr Bumber</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/
    Main.aspx" Style="position: relative; left: 0px; top: -15px;">Goto
    Main Page</asp:HyperLink>
    <asp:Button ID="Button1" runat="server" Style="left: 249px;
    position: relative; top: 73px; z-index: 100;"
    Text="Search" />
    <asp:Label ID="Label1" runat="server" Style="z-index: 104;
    left: 167px; position: absolute;
    top: 48px" Text="Enter A Partial Part Number"
    Width="230px" Font-Size="14pt"></asp:Label>
    <br />
    <asp:TextBox ID="TextBox1" runat="server" Style="left: 187px;
    position: relative;
    top: 49px; z-index: 102;"></asp:TextBox><br />
    <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/
    add_data_inventory.aspx"
    Style="left: 0px; position: relative; top: -33px"
    Width="141px">Goto Add Data Page</asp:HyperLink><br />
    &nbsp;</div>
    &nbsp;<br />
    <asp:AccessDataSource ID="AccessDataSource1" runat="server"
    ConflictDetection="CompareAllValues"
    DataFile="~/App_Data/Spare_Parts_II_BCPC.mdb"
    DeleteCommand="DELETE FROM [Inventory] WHERE [ID1] = ? AND [Mfr] = ?
    AND [MFR_PART#] = ? AND [Description] = ? AND [Shelving Unit] = ? AND
    [Shelf] = ? AND [Bin#] = ? AND [OnHand] = ?"
    InsertCommand="INSERT INTO [Inventory] ([Mfr],
    [MFR_PART#], [Description], [Shelving Unit], [Shelf], [Bin#],
    [OnHand], [ID1]) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
    OldValuesParameterFormatString="original_{0}"
    SelectCommand="SELECT [Mfr], [MFR_PART#] AS column1, [Description],
    [Shelving Unit] AS Shelving_Unit, [Shelf], [Bin#] AS column2,
    [OnHand], [ID1] FROM [Inventory] WHERE ([MFR_PART#] LIKE '%' + ? +
    '%')"
    UpdateCommand="UPDATE [Inventory] SET [Mfr] = ?,
    [MFR_PART#] = ?, [Description] = ?, [Shelving Unit] = ?, [Shelf] = ?,
    [Bin#] = ?, [OnHand] = ? AND [Mfr] = ? AND [MFR_PART#] = ? AND
    [Description] = ? AND [Shelving Unit] = ? AND [Shelf] = ? AND [Bin#]
    = ? AND [OnHand] = ?">
    <DeleteParameters>
    <asp:parameter Name="original_ID1" Type="Int32" />
    <asp:parameter Name="original_Mfr" Type="String" />
    <asp:parameter Name="original_column1" Type="String" /
    >

    <asp:parameter Name="original_Description"
    Type="String" />
    <asp:parameter Name="original_Shelving_Unit"
    Type="String" />
    <asp:parameter Name="original_Shelf" Type="String" />
    <asp:parameter Name="original_column2" Type="String" /
    >

    <asp:parameter Name="original_OnHand" Type="Double" />
    </DeleteParameters>
    <UpdateParameters>
    <asp:parameter Name="Mfr" Type="String" />
    <asp:parameter Name="column1" Type="String" />
    <asp:parameter Name="Description" Type="String" />
    <asp:parameter Name="Shelving_Unit" Type="String" />
    <asp:parameter Name="Shelf" Type="String" />
    <asp:parameter Name="column2" Type="String" />
    <asp:parameter Name="OnHand" Type="Double" />
    <asp:parameter Name="original_ID1" Type="Int32" />
    <asp:parameter Name="original_Mfr" Type="String" />
    <asp:parameter Name="original_column1" Type="String" /
    >

    <asp:parameter Name="original_Description"
    Type="String" />
    <asp:parameter Name="original_Shelving_Unit"
    Type="String" />
    <asp:parameter Name="original_Shelf" Type="String" />
    <asp:parameter Name="original_column2" Type="String" /
    >

    <asp:parameter Name="original_OnHand" Type="Double" />
    </UpdateParameters>
    <SelectParameters>
    <asp:ControlParameter ControlID="TextBox1"
    Name="column1" PropertyName="Text" Type="String" />
    </SelectParameters>
    <InsertParameters>
    <asp:parameter Name="Mfr" Type="String" />
    <asp:parameter Name="column1" Type="String" />
    <asp:parameter Name="Description" Type="String" />
    <asp:parameter Name="Shelving_Unit" Type="String" />
    <asp:parameter Name="Shelf" Type="String" />
    <asp:parameter Name="column2" Type="String" />
    <asp:parameter Name="OnHand" Type="Double" />
    <asp:parameter Name="ID1" Type="Int32" />
    </InsertParameters>
    </asp:AccessDataSource>
    <br />
    <br />
    <asp:GridView ID="GridView1" runat="server"
    AutoGenerateColumns="False" CellPadding="4"
    DataKeyNames="ID1" DataSourceID="AccessDataSource1"
    ForeColor="#333333" GridLines="None"
    Style="position: relative">
    <FooterStyle BackColor="#990000" Font-Bold="True"
    ForeColor="White" />
    <Columns>
    <asp:CommandField ShowEditButton="True" />
    <asp:BoundField DataField="Mfr" HeaderText="Mfr"
    SortExpression="Mfr" />
    <asp:BoundField DataField="column1"
    HeaderText="Mfr_Part_no" SortExpression="column1" />
    <asp:BoundField DataField="Description"
    HeaderText="Description" SortExpression="Description" />
    <asp:BoundField DataField="Shelving_Unit"
    HeaderText="Shelving_Unit" SortExpression="Shelving_Unit" />
    <asp:BoundField DataField="Shelf" HeaderText="Shelf"
    SortExpression="Shelf" />
    <asp:BoundField DataField="column2"
    HeaderText="Bin_No" SortExpression="column2" />
    <asp:BoundField DataField="OnHand" HeaderText="OnHand"
    SortExpression="OnHand" />
    <asp:BoundField DataField="ID1" HeaderText="ID1"
    InsertVisible="False" ReadOnly="True"
    SortExpression="ID1" />
    </Columns>
    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True"
    ForeColor="Navy" />
    <PagerStyle BackColor="#FFCC66" ForeColor="#333333"
    HorizontalAlign="Center" />
    <HeaderStyle BackColor="#990000" Font-Bold="True"
    ForeColor="White" />
    <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
    </form>
    </body>
    </html>
     
    , Aug 29, 2007
    #1
    1. Advertising

  2. Guest

    Your update command doesn't have a WHERE clause in it to specify which
    record to update, so yes it would appear to be normal that it is
    updating every record.

    --
    Mark Smith
    http://aspnetlibrary.com
     
    , Aug 29, 2007
    #2
    1. Advertising

  3. Steve Guest

    Sounds to me like you need to add a WHERE clause to your update
    statement that will limit the update to the row you're editing.


    Steve C.
    MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA


    wrote:
    > When I try and update using the gridview edit option, all of the
    > records in the entire Access database
    > get changed. Is this normal in gridview? Is there a way to change
    > this behavior? Or should I
    > be using a different control?
    >
    > Thanks
    >
    > Page Code is as follows:
    >
    > <%@ Page Language="VB" %>
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
    > www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    >
    >
    >
    > <html xmlns="http://www.w3.org/1999/xhtml" >
    > <head runat="server">
    > <title>Search Parts By Mfr Bumber</title>
    > </head>
    > <body>
    > <form id="form1" runat="server">
    > <div>
    > <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/
    > Main.aspx" Style="position: relative; left: 0px; top: -15px;">Goto
    > Main Page</asp:HyperLink>
    > <asp:Button ID="Button1" runat="server" Style="left: 249px;
    > position: relative; top: 73px; z-index: 100;"
    > Text="Search" />
    > <asp:Label ID="Label1" runat="server" Style="z-index: 104;
    > left: 167px; position: absolute;
    > top: 48px" Text="Enter A Partial Part Number"
    > Width="230px" Font-Size="14pt"></asp:Label>
    > <br />
    > <asp:TextBox ID="TextBox1" runat="server" Style="left: 187px;
    > position: relative;
    > top: 49px; z-index: 102;"></asp:TextBox><br />
    > <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/
    > add_data_inventory.aspx"
    > Style="left: 0px; position: relative; top: -33px"
    > Width="141px">Goto Add Data Page</asp:HyperLink><br />
    > &nbsp;</div>
    > &nbsp;<br />
    > <asp:AccessDataSource ID="AccessDataSource1" runat="server"
    > ConflictDetection="CompareAllValues"
    > DataFile="~/App_Data/Spare_Parts_II_BCPC.mdb"
    > DeleteCommand="DELETE FROM [Inventory] WHERE [ID1] = ? AND [Mfr] = ?
    > AND [MFR_PART#] = ? AND [Description] = ? AND [Shelving Unit] = ? AND
    > [Shelf] = ? AND [Bin#] = ? AND [OnHand] = ?"
    > InsertCommand="INSERT INTO [Inventory] ([Mfr],
    > [MFR_PART#], [Description], [Shelving Unit], [Shelf], [Bin#],
    > [OnHand], [ID1]) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
    > OldValuesParameterFormatString="original_{0}"
    > SelectCommand="SELECT [Mfr], [MFR_PART#] AS column1, [Description],
    > [Shelving Unit] AS Shelving_Unit, [Shelf], [Bin#] AS column2,
    > [OnHand], [ID1] FROM [Inventory] WHERE ([MFR_PART#] LIKE '%' + ? +
    > '%')"
    > UpdateCommand="UPDATE [Inventory] SET [Mfr] = ?,
    > [MFR_PART#] = ?, [Description] = ?, [Shelving Unit] = ?, [Shelf] = ?,
    > [Bin#] = ?, [OnHand] = ? AND [Mfr] = ? AND [MFR_PART#] = ? AND
    > [Description] = ? AND [Shelving Unit] = ? AND [Shelf] = ? AND [Bin#]
    > = ? AND [OnHand] = ?">
    > <DeleteParameters>
    > <asp:parameter Name="original_ID1" Type="Int32" />
    > <asp:parameter Name="original_Mfr" Type="String" />
    > <asp:parameter Name="original_column1" Type="String" /
    > <asp:parameter Name="original_Description"
    > Type="String" />
    > <asp:parameter Name="original_Shelving_Unit"
    > Type="String" />
    > <asp:parameter Name="original_Shelf" Type="String" />
    > <asp:parameter Name="original_column2" Type="String" /
    > <asp:parameter Name="original_OnHand" Type="Double" />
    > </DeleteParameters>
    > <UpdateParameters>
    > <asp:parameter Name="Mfr" Type="String" />
    > <asp:parameter Name="column1" Type="String" />
    > <asp:parameter Name="Description" Type="String" />
    > <asp:parameter Name="Shelving_Unit" Type="String" />
    > <asp:parameter Name="Shelf" Type="String" />
    > <asp:parameter Name="column2" Type="String" />
    > <asp:parameter Name="OnHand" Type="Double" />
    > <asp:parameter Name="original_ID1" Type="Int32" />
    > <asp:parameter Name="original_Mfr" Type="String" />
    > <asp:parameter Name="original_column1" Type="String" /
    > <asp:parameter Name="original_Description"
    > Type="String" />
    > <asp:parameter Name="original_Shelving_Unit"
    > Type="String" />
    > <asp:parameter Name="original_Shelf" Type="String" />
    > <asp:parameter Name="original_column2" Type="String" /
    > <asp:parameter Name="original_OnHand" Type="Double" />
    > </UpdateParameters>
    > <SelectParameters>
    > <asp:ControlParameter ControlID="TextBox1"
    > Name="column1" PropertyName="Text" Type="String" />
    > </SelectParameters>
    > <InsertParameters>
    > <asp:parameter Name="Mfr" Type="String" />
    > <asp:parameter Name="column1" Type="String" />
    > <asp:parameter Name="Description" Type="String" />
    > <asp:parameter Name="Shelving_Unit" Type="String" />
    > <asp:parameter Name="Shelf" Type="String" />
    > <asp:parameter Name="column2" Type="String" />
    > <asp:parameter Name="OnHand" Type="Double" />
    > <asp:parameter Name="ID1" Type="Int32" />
    > </InsertParameters>
    > </asp:AccessDataSource>
    > <br />
    > <br />
    > <asp:GridView ID="GridView1" runat="server"
    > AutoGenerateColumns="False" CellPadding="4"
    > DataKeyNames="ID1" DataSourceID="AccessDataSource1"
    > ForeColor="#333333" GridLines="None"
    > Style="position: relative">
    > <FooterStyle BackColor="#990000" Font-Bold="True"
    > ForeColor="White" />
    > <Columns>
    > <asp:CommandField ShowEditButton="True" />
    > <asp:BoundField DataField="Mfr" HeaderText="Mfr"
    > SortExpression="Mfr" />
    > <asp:BoundField DataField="column1"
    > HeaderText="Mfr_Part_no" SortExpression="column1" />
    > <asp:BoundField DataField="Description"
    > HeaderText="Description" SortExpression="Description" />
    > <asp:BoundField DataField="Shelving_Unit"
    > HeaderText="Shelving_Unit" SortExpression="Shelving_Unit" />
    > <asp:BoundField DataField="Shelf" HeaderText="Shelf"
    > SortExpression="Shelf" />
    > <asp:BoundField DataField="column2"
    > HeaderText="Bin_No" SortExpression="column2" />
    > <asp:BoundField DataField="OnHand" HeaderText="OnHand"
    > SortExpression="OnHand" />
    > <asp:BoundField DataField="ID1" HeaderText="ID1"
    > InsertVisible="False" ReadOnly="True"
    > SortExpression="ID1" />
    > </Columns>
    > <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
    > <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True"
    > ForeColor="Navy" />
    > <PagerStyle BackColor="#FFCC66" ForeColor="#333333"
    > HorizontalAlign="Center" />
    > <HeaderStyle BackColor="#990000" Font-Bold="True"
    > ForeColor="White" />
    > <AlternatingRowStyle BackColor="White" />
    > </asp:GridView>
    > </form>
    > </body>
    > </html>
    >
     
    Steve, Aug 29, 2007
    #3
  4. Bgreer5050 Guest

    I have searched high and low.....how do I write this Where clause so it is
    limited to the edit selected row?


    "Steve" <> wrote in message
    news:...
    > Sounds to me like you need to add a WHERE clause to your update statement
    > that will limit the update to the row you're editing.
    >
    >
    > Steve C.
    > MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA
    >
    >
    > wrote:
    >> When I try and update using the gridview edit option, all of the
    >> records in the entire Access database
    >> get changed. Is this normal in gridview? Is there a way to change
    >> this behavior? Or should I
    >> be using a different control?
    >>
    >> Thanks
    >>
    >> Page Code is as follows:
    >>
    >> <%@ Page Language="VB" %>
    >>
    >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
    >> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    >>
    >>
    >>
    >> <html xmlns="http://www.w3.org/1999/xhtml" >
    >> <head runat="server">
    >> <title>Search Parts By Mfr Bumber</title>
    >> </head>
    >> <body>
    >> <form id="form1" runat="server">
    >> <div>
    >> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/
    >> Main.aspx" Style="position: relative; left: 0px; top: -15px;">Goto
    >> Main Page</asp:HyperLink>
    >> <asp:Button ID="Button1" runat="server" Style="left: 249px;
    >> position: relative; top: 73px; z-index: 100;"
    >> Text="Search" />
    >> <asp:Label ID="Label1" runat="server" Style="z-index: 104;
    >> left: 167px; position: absolute;
    >> top: 48px" Text="Enter A Partial Part Number"
    >> Width="230px" Font-Size="14pt"></asp:Label>
    >> <br />
    >> <asp:TextBox ID="TextBox1" runat="server" Style="left: 187px;
    >> position: relative;
    >> top: 49px; z-index: 102;"></asp:TextBox><br />
    >> <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/
    >> add_data_inventory.aspx"
    >> Style="left: 0px; position: relative; top: -33px"
    >> Width="141px">Goto Add Data Page</asp:HyperLink><br />
    >> &nbsp;</div>
    >> &nbsp;<br />
    >> <asp:AccessDataSource ID="AccessDataSource1" runat="server"
    >> ConflictDetection="CompareAllValues"
    >> DataFile="~/App_Data/Spare_Parts_II_BCPC.mdb"
    >> DeleteCommand="DELETE FROM [Inventory] WHERE [ID1] = ? AND [Mfr] = ?
    >> AND [MFR_PART#] = ? AND [Description] = ? AND [Shelving Unit] = ? AND
    >> [Shelf] = ? AND [Bin#] = ? AND [OnHand] = ?"
    >> InsertCommand="INSERT INTO [Inventory] ([Mfr],
    >> [MFR_PART#], [Description], [Shelving Unit], [Shelf], [Bin#],
    >> [OnHand], [ID1]) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
    >> OldValuesParameterFormatString="original_{0}"
    >> SelectCommand="SELECT [Mfr], [MFR_PART#] AS column1, [Description],
    >> [Shelving Unit] AS Shelving_Unit, [Shelf], [Bin#] AS column2,
    >> [OnHand], [ID1] FROM [Inventory] WHERE ([MFR_PART#] LIKE '%' + ? +
    >> '%')"
    >> UpdateCommand="UPDATE [Inventory] SET [Mfr] = ?,
    >> [MFR_PART#] = ?, [Description] = ?, [Shelving Unit] = ?, [Shelf] = ?,
    >> [Bin#] = ?, [OnHand] = ? AND [Mfr] = ? AND [MFR_PART#] = ? AND
    >> [Description] = ? AND [Shelving Unit] = ? AND [Shelf] = ? AND [Bin#]
    >> = ? AND [OnHand] = ?">
    >> <DeleteParameters>
    >> <asp:parameter Name="original_ID1" Type="Int32" />
    >> <asp:parameter Name="original_Mfr" Type="String" />
    >> <asp:parameter Name="original_column1" Type="String" /
    >> <asp:parameter Name="original_Description"
    >> Type="String" />
    >> <asp:parameter Name="original_Shelving_Unit"
    >> Type="String" />
    >> <asp:parameter Name="original_Shelf" Type="String" />
    >> <asp:parameter Name="original_column2" Type="String" /
    >> <asp:parameter Name="original_OnHand" Type="Double" />
    >> </DeleteParameters>
    >> <UpdateParameters>
    >> <asp:parameter Name="Mfr" Type="String" />
    >> <asp:parameter Name="column1" Type="String" />
    >> <asp:parameter Name="Description" Type="String" />
    >> <asp:parameter Name="Shelving_Unit" Type="String" />
    >> <asp:parameter Name="Shelf" Type="String" />
    >> <asp:parameter Name="column2" Type="String" />
    >> <asp:parameter Name="OnHand" Type="Double" />
    >> <asp:parameter Name="original_ID1" Type="Int32" />
    >> <asp:parameter Name="original_Mfr" Type="String" />
    >> <asp:parameter Name="original_column1" Type="String" /
    >> <asp:parameter Name="original_Description"
    >> Type="String" />
    >> <asp:parameter Name="original_Shelving_Unit"
    >> Type="String" />
    >> <asp:parameter Name="original_Shelf" Type="String" />
    >> <asp:parameter Name="original_column2" Type="String" /
    >> <asp:parameter Name="original_OnHand" Type="Double" />
    >> </UpdateParameters>
    >> <SelectParameters>
    >> <asp:ControlParameter ControlID="TextBox1"
    >> Name="column1" PropertyName="Text" Type="String" />
    >> </SelectParameters>
    >> <InsertParameters>
    >> <asp:parameter Name="Mfr" Type="String" />
    >> <asp:parameter Name="column1" Type="String" />
    >> <asp:parameter Name="Description" Type="String" />
    >> <asp:parameter Name="Shelving_Unit" Type="String" />
    >> <asp:parameter Name="Shelf" Type="String" />
    >> <asp:parameter Name="column2" Type="String" />
    >> <asp:parameter Name="OnHand" Type="Double" />
    >> <asp:parameter Name="ID1" Type="Int32" />
    >> </InsertParameters>
    >> </asp:AccessDataSource>
    >> <br />
    >> <br />
    >> <asp:GridView ID="GridView1" runat="server"
    >> AutoGenerateColumns="False" CellPadding="4"
    >> DataKeyNames="ID1" DataSourceID="AccessDataSource1"
    >> ForeColor="#333333" GridLines="None"
    >> Style="position: relative">
    >> <FooterStyle BackColor="#990000" Font-Bold="True"
    >> ForeColor="White" />
    >> <Columns>
    >> <asp:CommandField ShowEditButton="True" />
    >> <asp:BoundField DataField="Mfr" HeaderText="Mfr"
    >> SortExpression="Mfr" />
    >> <asp:BoundField DataField="column1"
    >> HeaderText="Mfr_Part_no" SortExpression="column1" />
    >> <asp:BoundField DataField="Description"
    >> HeaderText="Description" SortExpression="Description" />
    >> <asp:BoundField DataField="Shelving_Unit"
    >> HeaderText="Shelving_Unit" SortExpression="Shelving_Unit" />
    >> <asp:BoundField DataField="Shelf" HeaderText="Shelf"
    >> SortExpression="Shelf" />
    >> <asp:BoundField DataField="column2"
    >> HeaderText="Bin_No" SortExpression="column2" />
    >> <asp:BoundField DataField="OnHand" HeaderText="OnHand"
    >> SortExpression="OnHand" />
    >> <asp:BoundField DataField="ID1" HeaderText="ID1"
    >> InsertVisible="False" ReadOnly="True"
    >> SortExpression="ID1" />
    >> </Columns>
    >> <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
    >> <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True"
    >> ForeColor="Navy" />
    >> <PagerStyle BackColor="#FFCC66" ForeColor="#333333"
    >> HorizontalAlign="Center" />
    >> <HeaderStyle BackColor="#990000" Font-Bold="True"
    >> ForeColor="White" />
    >> <AlternatingRowStyle BackColor="White" />
    >> </asp:GridView>
    >> </form>
    >> </body>
    >> </html>
    >>
     
    Bgreer5050, Aug 29, 2007
    #4
  5. Sergio E. Guest

    use the fields included in the promary key

    if your table has a idtable field, then use where
    idfield=selectedrow_idtable field

    as a tip, you can use the wizard to create an accessdatasource, select your
    mdb, select the table, the fields and there is a button named "advanced", in
    the window that is opened, select generate insert, update and delete
    statements then ok, then next, then finish. it will generate all you need to
    do this works. The only problem you can get is if you haven't defined a
    primary key.

    greetings
    Sergio E.

    "Bgreer5050" <> escribió en el mensaje
    news:EDkBi.12479$...
    >I have searched high and low.....how do I write this Where clause so it is
    >limited to the edit selected row?
    >
    >
    > "Steve" <> wrote in message
    > news:...
    >> Sounds to me like you need to add a WHERE clause to your update statement
    >> that will limit the update to the row you're editing.
    >>
    >>
    >> Steve C.
    >> MCSD,MCAD,MCSE,MCP+I,CNE,CNA,CCNA
    >>
    >>
    >> wrote:
    >>> When I try and update using the gridview edit option, all of the
    >>> records in the entire Access database
    >>> get changed. Is this normal in gridview? Is there a way to change
    >>> this behavior? Or should I
    >>> be using a different control?
    >>>
    >>> Thanks
    >>>
    >>> Page Code is as follows:
    >>>
    >>> <%@ Page Language="VB" %>
    >>>
    >>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
    >>> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    >>>
    >>>
    >>>
    >>> <html xmlns="http://www.w3.org/1999/xhtml" >
    >>> <head runat="server">
    >>> <title>Search Parts By Mfr Bumber</title>
    >>> </head>
    >>> <body>
    >>> <form id="form1" runat="server">
    >>> <div>
    >>> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/
    >>> Main.aspx" Style="position: relative; left: 0px; top: -15px;">Goto
    >>> Main Page</asp:HyperLink>
    >>> <asp:Button ID="Button1" runat="server" Style="left: 249px;
    >>> position: relative; top: 73px; z-index: 100;"
    >>> Text="Search" />
    >>> <asp:Label ID="Label1" runat="server" Style="z-index: 104;
    >>> left: 167px; position: absolute;
    >>> top: 48px" Text="Enter A Partial Part Number"
    >>> Width="230px" Font-Size="14pt"></asp:Label>
    >>> <br />
    >>> <asp:TextBox ID="TextBox1" runat="server" Style="left: 187px;
    >>> position: relative;
    >>> top: 49px; z-index: 102;"></asp:TextBox><br />
    >>> <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/
    >>> add_data_inventory.aspx"
    >>> Style="left: 0px; position: relative; top: -33px"
    >>> Width="141px">Goto Add Data Page</asp:HyperLink><br />
    >>> &nbsp;</div>
    >>> &nbsp;<br />
    >>> <asp:AccessDataSource ID="AccessDataSource1" runat="server"
    >>> ConflictDetection="CompareAllValues"
    >>> DataFile="~/App_Data/Spare_Parts_II_BCPC.mdb"
    >>> DeleteCommand="DELETE FROM [Inventory] WHERE [ID1] = ? AND [Mfr] = ?
    >>> AND [MFR_PART#] = ? AND [Description] = ? AND [Shelving Unit] = ? AND
    >>> [Shelf] = ? AND [Bin#] = ? AND [OnHand] = ?"
    >>> InsertCommand="INSERT INTO [Inventory] ([Mfr],
    >>> [MFR_PART#], [Description], [Shelving Unit], [Shelf], [Bin#],
    >>> [OnHand], [ID1]) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
    >>> OldValuesParameterFormatString="original_{0}"
    >>> SelectCommand="SELECT [Mfr], [MFR_PART#] AS column1, [Description],
    >>> [Shelving Unit] AS Shelving_Unit, [Shelf], [Bin#] AS column2,
    >>> [OnHand], [ID1] FROM [Inventory] WHERE ([MFR_PART#] LIKE '%' + ? +
    >>> '%')"
    >>> UpdateCommand="UPDATE [Inventory] SET [Mfr] = ?,
    >>> [MFR_PART#] = ?, [Description] = ?, [Shelving Unit] = ?, [Shelf] = ?,
    >>> [Bin#] = ?, [OnHand] = ? AND [Mfr] = ? AND [MFR_PART#] = ? AND
    >>> [Description] = ? AND [Shelving Unit] = ? AND [Shelf] = ? AND [Bin#]
    >>> = ? AND [OnHand] = ?">
    >>> <DeleteParameters>
    >>> <asp:parameter Name="original_ID1" Type="Int32" />
    >>> <asp:parameter Name="original_Mfr" Type="String" />
    >>> <asp:parameter Name="original_column1" Type="String" /
    >>> <asp:parameter Name="original_Description"
    >>> Type="String" />
    >>> <asp:parameter Name="original_Shelving_Unit"
    >>> Type="String" />
    >>> <asp:parameter Name="original_Shelf" Type="String" />
    >>> <asp:parameter Name="original_column2" Type="String" /
    >>> <asp:parameter Name="original_OnHand" Type="Double" />
    >>> </DeleteParameters>
    >>> <UpdateParameters>
    >>> <asp:parameter Name="Mfr" Type="String" />
    >>> <asp:parameter Name="column1" Type="String" />
    >>> <asp:parameter Name="Description" Type="String" />
    >>> <asp:parameter Name="Shelving_Unit" Type="String" />
    >>> <asp:parameter Name="Shelf" Type="String" />
    >>> <asp:parameter Name="column2" Type="String" />
    >>> <asp:parameter Name="OnHand" Type="Double" />
    >>> <asp:parameter Name="original_ID1" Type="Int32" />
    >>> <asp:parameter Name="original_Mfr" Type="String" />
    >>> <asp:parameter Name="original_column1" Type="String" /
    >>> <asp:parameter Name="original_Description"
    >>> Type="String" />
    >>> <asp:parameter Name="original_Shelving_Unit"
    >>> Type="String" />
    >>> <asp:parameter Name="original_Shelf" Type="String" />
    >>> <asp:parameter Name="original_column2" Type="String" /
    >>> <asp:parameter Name="original_OnHand" Type="Double" />
    >>> </UpdateParameters>
    >>> <SelectParameters>
    >>> <asp:ControlParameter ControlID="TextBox1"
    >>> Name="column1" PropertyName="Text" Type="String" />
    >>> </SelectParameters>
    >>> <InsertParameters>
    >>> <asp:parameter Name="Mfr" Type="String" />
    >>> <asp:parameter Name="column1" Type="String" />
    >>> <asp:parameter Name="Description" Type="String" />
    >>> <asp:parameter Name="Shelving_Unit" Type="String" />
    >>> <asp:parameter Name="Shelf" Type="String" />
    >>> <asp:parameter Name="column2" Type="String" />
    >>> <asp:parameter Name="OnHand" Type="Double" />
    >>> <asp:parameter Name="ID1" Type="Int32" />
    >>> </InsertParameters>
    >>> </asp:AccessDataSource>
    >>> <br />
    >>> <br />
    >>> <asp:GridView ID="GridView1" runat="server"
    >>> AutoGenerateColumns="False" CellPadding="4"
    >>> DataKeyNames="ID1" DataSourceID="AccessDataSource1"
    >>> ForeColor="#333333" GridLines="None"
    >>> Style="position: relative">
    >>> <FooterStyle BackColor="#990000" Font-Bold="True"
    >>> ForeColor="White" />
    >>> <Columns>
    >>> <asp:CommandField ShowEditButton="True" />
    >>> <asp:BoundField DataField="Mfr" HeaderText="Mfr"
    >>> SortExpression="Mfr" />
    >>> <asp:BoundField DataField="column1"
    >>> HeaderText="Mfr_Part_no" SortExpression="column1" />
    >>> <asp:BoundField DataField="Description"
    >>> HeaderText="Description" SortExpression="Description" />
    >>> <asp:BoundField DataField="Shelving_Unit"
    >>> HeaderText="Shelving_Unit" SortExpression="Shelving_Unit" />
    >>> <asp:BoundField DataField="Shelf" HeaderText="Shelf"
    >>> SortExpression="Shelf" />
    >>> <asp:BoundField DataField="column2"
    >>> HeaderText="Bin_No" SortExpression="column2" />
    >>> <asp:BoundField DataField="OnHand" HeaderText="OnHand"
    >>> SortExpression="OnHand" />
    >>> <asp:BoundField DataField="ID1" HeaderText="ID1"
    >>> InsertVisible="False" ReadOnly="True"
    >>> SortExpression="ID1" />
    >>> </Columns>
    >>> <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
    >>> <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True"
    >>> ForeColor="Navy" />
    >>> <PagerStyle BackColor="#FFCC66" ForeColor="#333333"
    >>> HorizontalAlign="Center" />
    >>> <HeaderStyle BackColor="#990000" Font-Bold="True"
    >>> ForeColor="White" />
    >>> <AlternatingRowStyle BackColor="White" />
    >>> </asp:GridView>
    >>> </form>
    >>> </body>
    >>> </html>
    >>>

    >
    >
     
    Sergio E., Sep 6, 2007
    #5
    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. Hartmut Schroth
    Replies:
    3
    Views:
    3,516
    Hartmut Schroth
    Dec 1, 2003
  2. =?Utf-8?B?a2Vu?=
    Replies:
    1
    Views:
    10,363
    Wiktor Zychla [C# MVP]
    Jan 23, 2006
  3. Replies:
    4
    Views:
    967
    Sergio E.
    Sep 6, 2007
  4. Henke

    Update without using Edit and Update button

    Henke, May 30, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    162
    Brock Allen
    Jun 1, 2006
  5. Jaime Stuardo

    GridView control enters edit mode when I click Edit link twice

    Jaime Stuardo, Apr 7, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    418
    Jaime Stuardo
    Apr 7, 2006
Loading...

Share This Page