Удаляю, как написано в книжке:
Sub Click_Grid(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs)
Dim DBConn As OleDbConnection
Dim DBDelete As New OleDbCommand
Dim DBCommand As OleDbDataAdapter
Dim DSPageData As New DataSet
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" & Server.MapPath("./base/baza.mdb;"))
DBDelete.CommandText = "DELETE FROM ShoppingItems WHERE ShoppingID =" & E.Item.Cells(6).Text
DBDelete.Connection = DBConn
DBDelete.Connection.Open()
DBDelete.ExecuteNonQuery()
End Sub
КОД ДАТАГРИДА:
<asp:datagrid id="DGShop" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 104px" runat="server"
Font-Size="X-Small" CellPadding="4" BackColor="White" BorderWidth="1px" BorderStyle="None"
BorderColor="#CC9966" AllowPaging="True" AutoGenerateColumns="False" OnItemCommand="Click_Grid"
Height="248px" Width="664px">
<SelectedItemStyle Font-Bold="True" ForeColor="#663399" BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"></HeaderStyle>
<FooterStyle ForeColor="#330099" BackColor="#FFFFCC"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="PlatokName" HeaderText="Название:"></asp:BoundColumn>
<asp:BoundColumn DataField="PlatokNRis" HeaderText="Рисунок №:"></asp:BoundColumn>
<asp:BoundColumn DataField="PlatokSize" HeaderText="Размер:"></asp:BoundColumn>
<asp:BoundColumn DataField="PlatokPrice" HeaderText="Цена за 1 шт.:"></asp:BoundColumn>
<asp:BoundColumn DataField="PlatokStatus" HeaderText="Статус:"></asp:BoundColumn>
<asp:HyperLinkColumn Text="Смотреть" DataNavigateUrlField="PlatokID" DataNavigateUrlFormatString="Preview.aspx?ID={0}"
HeaderText="Просмотр:" NavigateUrl="ID"></asp:HyperLinkColumn>
<asp:ButtonColumn Text="Удалить" HeaderText="Удаление:" CommandName="cmdRemoveItem"></asp:ButtonColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="#330099" BackColor="#FFFFCC" PageButtonCount="5"
Mode="NumericPages"></PagerStyle>
</asp:datagrid>
И ещё как "перевести на русский" строку E.Item.Cells(6).Text
Всем ответившим спасибо!
Ответить
|