在mysql vb.net中插入选中的ccheckbox的值

时间:2014-10-01 04:50:11

标签: vb.net checkbox datagridview

如何在数据网格视图中获取已选中复选框的值,并将所选行插入数据库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

1 个答案:

答案 0 :(得分:0)

尝试此编码

Dim checkBox1 As CheckBoxlist = GridView1.Rows(e.RowIndex) .FindControl("Checkbox1")
    if checkbox1.checked=true then
        For Each li As ListItem In checkBox1 .Items
        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
        next
    End If
    else
    End If