Delete with DataGrid in ASP.NET 2.0

Discussion in 'ASP .Net Datagrid Control' started by Stefan Gsundbrunn, Jul 4, 2005.

  1. Hi,

    does anybody know how to fix this issue in ASP.NET 2.0 (quite simple for
    you I guess - I started with my first steps yesterday).

    The problem is that the "Delete" does not work (it even creates no
    errors). Edit also does not work.

    If i use (with the same parameters) the DetailsView control, everything
    works perfectly.

    Just a "bug" in the beta? Or did i forgot a parameter?

    Any help appreciated.

    Thanks in advance

    Stefan


    I use this code:

    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
    Title="Untitled Page" %>

    <script runat="server">

    Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e
    As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)

    End Sub

    Protected Sub SqlDataSource1_Selecting1(ByVal sender As Object,
    ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)

    End Sub

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As
    Object, ByVal e As System.EventArgs)


    End Sub

    Protected Sub SqlDataSource2_Selecting(ByVal sender As Object,
    ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs)

    End Sub
    </script>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
    Runat="Server">
    &nbsp; &nbsp; &nbsp;&nbsp;<br />
    &nbsp;
    <br />
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
    AllowSorting="True"
    AutoGenerateColumns="False" AutoGenerateDeleteButton="True"
    AutoGenerateEditButton="True"
    DataKeyNames="ftbAnglerId" DataSourceID="SqlDataSource1">
    <Columns>
    <asp:BoundField DataField="ftbAnglerId"
    HeaderText="ftbAnglerId" InsertVisible="False"
    ReadOnly="True" SortExpression="ftbAnglerId" />
    <asp:BoundField DataField="ftbAnglerName"
    HeaderText="ftbAnglerName" SortExpression="ftbAnglerName" />
    <asp:BoundField DataField="ftbAnglerVorName"
    HeaderText="ftbAnglerVorName" SortExpression="ftbAnglerVorName" />
    <asp:BoundField DataField="ftbAnglerGender"
    HeaderText="ftbAnglerGender" SortExpression="ftbAnglerGender" />
    <asp:BoundField DataField="ftbAnglerEmail"
    HeaderText="ftbAnglerEmail" SortExpression="ftbAnglerEmail" />
    <asp:BoundField DataField="ftbAnglerType"
    HeaderText="ftbAnglerType" SortExpression="ftbAnglerType" />
    <asp:BoundField DataField="ftbAnglerPassWord"
    HeaderText="ftbAnglerPassWord" SortExpression="ftbAnglerPassWord" />
    <asp:BoundField DataField="ftbAnglerIsGuestFrom"
    HeaderText="ftbAnglerIsGuestFrom"
    SortExpression="ftbAnglerIsGuestFrom" />
    <asp:BoundField DataField="ftbAnglerIsAdmin"
    HeaderText="ftbAnglerIsAdmin" SortExpression="ftbAnglerIsAdmin" />
    </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:fangtagebuchConnectionString1 %>"
    DeleteCommand="DELETE from ftbAngler WHERE ftbAnglerId =
    @ftbAnglerId" SelectCommand="SELECT [ftbAnglerId], [ftbAnglerName],
    [ftbAnglerVorName], [ftbAnglerGender], [ftbAnglerEmail],
    [ftbAnglerType], [ftbAnglerPassWord], [ftbAnglerIsGuestFrom],
    [ftbAnglerIsAdmin] FROM [ftbAngler]">
    <DeleteParameters>
    <asp:parameter Name="ftbAnglerId" />
    </DeleteParameters>
    </asp:SqlDataSource>
    </asp:Content>
    Stefan Gsundbrunn, Jul 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. RSB
    Replies:
    6
    Views:
    7,676
    Karim
    May 19, 2004
  2. Sandeep Grover

    delete on delete !

    Sandeep Grover, Jul 12, 2003, in forum: C++
    Replies:
    19
    Views:
    617
    Chris \( Val \)
    Jul 22, 2003
  3. HeroOfSpielburg
    Replies:
    1
    Views:
    389
    Alf P. Steinbach
    Aug 6, 2003
  4. Fred Zolar
    Replies:
    0
    Views:
    221
    Fred Zolar
    Apr 1, 2004
  5. Jimmy

    Howto insert delete rows into a ASP.net datagrid?

    Jimmy, Apr 20, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    128
Loading...

Share This Page