首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在mysql vb.net中插入选中复选框的值

问在mysql vb.net中插入选中复选框的值
EN

Stack Overflow用户
提问于 2014-10-01 12:50:11
回答 1查看 1.7K关注 0票数 0

如何在数据网格视图中获取选中复选框的值,并在数据库mysql中插入选定的行。

我有列名为cloth_id,cloth_desc quantity cloth_desc price如果选中了行中的复选框,那么数量和价格将乘以得到要支付的总金额。提前感谢:)这段代码只适用于一行。当多行被选中时,帮助我查询。谢谢:)

代码语言:javascript
复制
 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
EN

回答 1

Stack Overflow用户

发布于 2014-10-01 14:28:23

请尝试此编码

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26134322

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档