привет ребята
ест датагрид в асп.нет форме
и в этом датагрид ест боттон для удалит
данные помешает датагрид
но тогда я нажимаю удалит вообше ничего не изменят в датагрид и не удаляет
смотрите пожалуйста
это код датагрид
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.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
<asp:DataGrid
id="dgShoppingCart"
AutoGenerateColumns="False"
Width="90%"
BackColor="Beige"
AlternatingItemStyle-BackColor="Cornsilk"
BorderColor="Black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Names="Arial"
Font-Size="8pt"
ForeColor="Black"
HeaderStyle-BackColor="BurlyWood"
HeaderStyle-Font-Bold="true"
OnItemCommand="Click_Grid"
runat="server" >
<Columns>
<asp:BoundColumn
HeaderText="Mal"
DataField="ProductName"
/>
<asp:BoundColumn
HeaderText="Say"
DataField="Quantity"
/>
<asp:BoundColumn
HeaderText="Qiymet"
DataField="Price"
DataFormatString="{0:C}"
/>
<asp:BoundColumn
HeaderText="Catdirilma Qiymeti"
DataField="Shipping"
DataFormatString="{0:C}"
/>
<asp:BoundColumn
DataField="ShoppingCartItemID"
Visible="true"
/>
<asp:ButtonColumn
HeaderText="Silmek Ucun Linke Toxunun"
ButtonType="LinkButton"
Text="Sil"
CommandName="cmdRemoveItem"
/>
</Columns>
</asp:DataGrid>
и code
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.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
Protected Sub Click_Grid(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs)
Dim DBConn As SqlConnection
Dim DBDelete As New SqlCommand
Dim DBCommand As SqlDataAdapter
Dim DSPageData As New DataSet
DBConn = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\HP\Documents\Visual Studio 2010\Projects\emagazin\emagazin\App_Data\emagaza.mdf;Integrated Security=True;User Instance=True")
DBDelete.CommandText = "Delete from ShoppingCartItems " _
& "Where ShoppingCartItemID = " _
& E.Item.Cells(4).Text
DBConn = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\HP\Documents\Visual Studio 2010\Projects\emagazin\emagazin\App_Data\emagaza.mdf;Integrated Security=True;User Instance=True")
DBCommand = New SqlDataAdapter _
("select ShoppingCartItemID, ProductName, " _
& "Quantity, Price, Shipping from " _
& "ShoppingCartItems where " _
& "CustomerID = " & Session("CustomerID") _
& "Order by ProductName" _
, DBConn)
DBCommand.Fill(DSPageData, _
"ShoppingCart")
dgShoppingCart.DataSource = _
DSPageData.Tables("ShoppingCart").DefaultView
dgShoppingCart.DataBind()
If DSPageData.Tables("ShoppingCart").Rows.Count = 0 Then
lblPriceTotal.Text = "Sizin Sebetde " _
& "Mal Yoxdur."
lblShippingTotal.Text = ""
lblGrandTotal.Text = ""
Else
DBCommand = New SqlDataAdapter _
("Select sum(Price) as PriceSum, " _
& "Sum(Shipping) as ShippingSum From " _
& "ShoppingCartItems where " _
& "CustomerID = " & Session("CustomerID") _
, DBConn)
DBCommand.Fill(DSPageData, _
"Totals")
lblPriceTotal.Text = "Cemi: " _
& FormatCurrency(DSPageData.Tables("Totals"). _
Rows(0).Item("PriceSum"))
lblShippingTotal.Text = "Catdirilma: " _
& FormatCurrency(DSPageData.Tables("Totals").
Rows(0).Item("ShippingSum"))
lblGrandTotal.Text = "Yekun: " _
& FormatCurrency(DSPageData.Tables("Totals"). _
Rows(0).Item("PriceSum") + _
DSPageData.Tables("Totals").
Rows(0).Item("ShippingSum"))
End If
End Sub