Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to get the value of the checked check box in data grid view and insert the selected row in database mysql.

i have the column names cloth_id, cloth_desc quantity and price
if the check box in the row was checked then the quantity and price will be multiplied to get the total amount to be paid. thanks in advance :)
This code is good for only 1 row. help me in query when multiple row was checked.
thanks :)

VB
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
Posted
Updated 30-Sep-14 19:21pm
v4
Comments
Sinisa Hajnal 1-Oct-14 3:47am    
Where is this code of yours? I mean in which event / method? It works for all rows except first one...

Also, do you need to save checked on button click? Or some other event? Below is the solution for the button click

1 solution

VB
Protected Sub btnSave_Click(sender as Object,  e as EventArgs) 

    For Each grv as DataGridViewRow in DataGridView1.Rows

        If grv.Cells("checkboxcolumnname").Checked 
             ' your save code
        End If
    Next

End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900