这是我说的代码,不能刷新的。VB。net写的
绑定的代码:
Sub GridBind()
Dim MenuId As Integer = Request.QueryString(MenuId)
Dim cn As New OleDbConnection(dmd.dbpath)
Dim SqlStr As String
If MenuId <= 0 Then
SqlStr = "Select * from Product"
Else
SqlStr = "Select * from Product where MenuCategoryId=" & MenuId
End If
Dim Da As New OleDbDataAdapter(SqlStr, cn)
Dim Ds As New DataSet
Da.Fill(Ds, "Product")
ProductGrid.DataKeyField = "ProductId"
ProductGrid.DataSource = Ds.Tables("Product")
ProductGrid.DataBind()
End Sub
'删除
Sub DeleteProduct(ByVal Source As Object, ByVal E As DataGridCommandEventArgs)
Dim cn As New OleDbConnection(dmd.dbpath)
Dim ProductID As String = ProductGrid.DataKeys(E.Item.ItemIndex)
Dim SqlStr As String = "Delete from Product where ProductId=" & ProductID
Dim Command As New OleDbCommand(SqlStr, cn)
cn.Open()
Command.ExecuteNonQuery()
ProductGrid.EditItemIndex = -1
GridBind()
End Sub