【问题标题】:insert the value of the checked ccheckbox in mysql vb.net在 mysql vb.net 中插入选中复选框的值
【发布时间】: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


【解决方案1】:

试试这个编码

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

【讨论】:

  • datagridviewWinform 的控制。
猜你喜欢
  • 2015-07-07
  • 1970-01-01
  • 2011-09-08
  • 2017-11-15
  • 2016-01-27
  • 1970-01-01
  • 2014-10-15
  • 2012-08-20
  • 1970-01-01
相关资源
最近更新 更多