Je voudrais supprimer un enregistrement de ma table mais auparavant demander une confirmation à l'utilisateur .
Mais la méthode Delete de ma classe Confirmation n'est pas visible dans le code html puisque la compil génère cette erreur:
'Delete' n'est pas un membre de 'ASP.default2_aspx'

un bout de ma classe Confirmation
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Public Class ConfirmDelDG
        Inherits System.Web.UI.Page
 
        Protected WithEvents dtgProducts As System.Web.UI.WebControls.DataGrid
        Private strConnection As String = ConfigurationSettings.AppSettings("SqlServer")
        Private strSql As String = "SELECT ProductID, ProductName, UnitPrice " _
                                 & "FROM Products WHERE CategoryID = 1"
        Private objConn As SqlConnection
 
 
        Sub Delete(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs)
 
            ' recuperer l'id
            Dim ProductID As System.Int32 = System.Convert.ToInt32(E.Item.Cells(0).Text)
 
            dtgProducts.EditItemIndex = -1
 
            ' creation et lancement d'un dataSet
            Connect()
            Dim adapter As New SqlDataAdapter(strSql, objConn)
            Dim ds As New DataSet()
            adapter.Fill(ds, "Products")
            Disconnect()
 
 
            Dim tbl As DataTable = ds.Tables("Products")
            tbl.PrimaryKey = New DataColumn() _
                            { _
                              tbl.Columns("ProductID") _
                            }
            Dim row As DataRow = tbl.Rows.Find(ProductID)
            row.Delete()
 
            dtgProducts.DataSource = ds.Tables("Products")
            dtgProducts.DataBind()
 
        End Sub
 
    End Class
et mon datagrid
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
         CellPadding="6" AutoGenerateColumns="False"
              OnDeleteCommand="Delete" BorderColor="#999999" 
              BorderStyle="None" BorderWidth="1px" 
              BackColor="White" GridLines="Vertical">
  <AlternatingItemStyle BackColor="Gainsboro" />
  <ItemStyle ForeColor="Black" BackColor="#EEEEEE" />
  <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084" />
  <Columns>
    <asp:BoundColumn Visible="False" DataField="ProductID" ReadOnly="True" />
    <asp:BoundColumn DataField="ProductName" ReadOnly="True" HeaderText="Name" />
    <asp:BoundColumn DataField="UnitPrice" HeaderText="Price" DataFormatString="{0:c}" >
        <ItemStyle HorizontalAlign="Right" />
    </asp:BoundColumn>
      <asp:ButtonColumn CommandName="Delete" Text="Supprimer"></asp:ButtonColumn>
  </Columns>
</asp:DataGrid>
Merci pour toute suggestion!