can't update a GridView asp.net 2.0

Discussion in 'ASP .Net Web Controls' started by rob merritt, Mar 4, 2005.

  1. rob merritt

    rob merritt Guest

    Hi

    I am trying to update via an datagrid only nothing seems to happen
    how would I diplay what the update query looks like msgbox
    reponse.write? where do I put em?

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <script runat="server">
    void DetailsView1_ItemUpdated(Object sender,
    DetailsViewUpdatedEventArgs e)
    {
    GridView1.DataBind();
    }
    void DetailsView1_ItemInserted(Object sender,
    DetailsViewInsertedEventArgs e)
    {
    GridView1.DataBind();
    }
    void DetailsView1_ItemDeleted(Object sender,
    DetailsViewDeletedEventArgs e)
    {
    GridView1.DataBind();
    }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Editing Access Database</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:AccessDataSource ID="AccessDataSource1" Runat="server"
    DataFile="data\pubs.mdb"
    SelectCommand="select * from [authors],[books] where au_id
    = author_key" >
    </asp:AccessDataSource>
    <asp:GridView ID="GridView1" Runat="server" AllowPaging="True"
    AllowSorting="True" DataSourceID="AccessDataSource1"
    DataKeyNames="au_id" AutoGenerateSelectButton="True">
    </asp:GridView>
    <asp:AccessDataSource ID="AccessDataSource2" Runat="server"
    DataFile="data\pubs.mdb"
    SelectCommand="select * from [authors],[books] where au_id
    = author_key"
    DeleteCommand="DELETE FROM [authors] WHERE [au_id] = ?"
    UpdateCommand="UPDATE [books] SET [book_title] = ? WHERE
    [author_key] = ?"
    InsertCommand="INSERT INTO [authors] ([au_id], [au_lname],
    [au_fname], [phone], [address], [city], [state], [zip], [contract],
    [author_key], [book_title]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
    FilterExpression="au_id='@au_id'">
    <FilterParameters>
    <asp:ControlParameter Name="au_id"
    ControlID="GridView1"
    PropertyName="SelectedValue"></asp:ControlParameter>
    </FilterParameters>
    </asp:AccessDataSource>
    <asp:DetailsView ID="DetailsView1" Runat="server"
    AutoGenerateDeleteButton="True"
    AutoGenerateEditButton="True"
    DataSourceID="AccessDataSource2" DataKeyNames="au_id"
    AutoGenerateInsertButton="True"
    onitemupdated="DetailsView1_ItemUpdated"
    oniteminserted="DetailsView1_ItemInserted"
    onitemdeleted="DetailsView1_ItemDeleted">
    </asp:DetailsView>
    </div>
    </form>
    </body>
    </html>
     
    rob merritt, Mar 4, 2005
    #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. rob merritt

    trying to update a gridview asp.net 2.0

    rob merritt, Mar 4, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    2,563
    rob merritt
    Mar 4, 2005
  2. mesut
    Replies:
    0
    Views:
    673
    mesut
    Feb 19, 2007
  3. Evan M.
    Replies:
    1
    Views:
    1,222
    Evan M.
    Apr 18, 2007
  4. Replies:
    4
    Views:
    967
    Sergio E.
    Sep 6, 2007
  5. Urs Eichmann
    Replies:
    2
    Views:
    291
    Urs Eichmann
    Sep 22, 2006
Loading...

Share This Page