【发布时间】:2014-10-01 14:28:22
【问题描述】:
如何在数据网格视图中获取选中复选框的值并将选定的行插入数据库mysql中。
我有列名cloth_id、cloth_desc 数量和价格 如果选中该行中的复选框,则将数量和价格相乘以获得要支付的总金额。提前致谢 :) 此代码仅适用于 1 行。检查多行时帮助我查询。 谢谢:)
If e.RowIndex >= 0 Then
Dim row As DataGridViewRow
Dim amount, qty, prod As Double
row = Me.DataGridView1.Rows(e.RowIndex)
amount = row.Cells("Price").Value.ToString
qty = row.Cells("Qty").Value.ToString
prod = amount * qty
kg.Text = prod
End If
【问题讨论】:
-
使用
For Each循环遍历所有行,检查是否检查了CheckBox,如果是,则使用您的代码创建sql 查询。如果查询包含新行,则在循环后运行它...
标签: vb.net checkbox datagridview