怎样实现点击按钮添加datatable中的行
我想在页面里实现如下:做一个购物车,点击购物按钮后,从数据库newproduct中的product表中检索数据在datatable中,再点击购物按钮,增加一行。
我的Page_Prerender中写了:
Sub Page_Load dstProduct = New DataSet() conNewProduct = New SqlConnection("Server = localhost;Trusted_Connection = SSPI;Database = newproduct") dadProduct = New SqlDataAdapter("Select product_ID,product_name,product_price from product where product_ID = @ProductID",conNewProduct) dadProduct.Selectcommand.Parameters.Add("@ProductID",intProductID) dadProduct.MissingSchemaAction = MissingSchemaAction.AddWithKey cbProduct = New SqlCommandBuilder(dadProduct) dadProduct.Fill(dstProduct,"ShoppingCart") dgrdProduct.DataSource = dstProduct dgrdProduct.DataBind()
End Sub