I am developing a Windows Forms Based Application using dbo.database and Visual Basic:

I populate some Orders in DataGridView1 using LINQ 2 SQL from "tbl_Orders" where OrderStatus is "Pending". I change OrderStatus Column Type to "CheckBox" in DataGridView, Now I want that when I select some records (Orders) by checking respective checkboxes and click on "btn_UpdateStatus" Button, program pick OrderID's of only selected orders and update OrderStatus of Only selected Records (Orders) from "Pending" to "Completed" in Database Table "tbl_Orders" and DataGridView1 should be Refreshed.

I am using VB, Kindly help me with complete solution?

Code Im using is:

Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
        Dim ID As Integer = DirectCast(DataGridViewIU68E.SelectedRows(0).Cells("EvaluationIDDataGridViewTextBoxColumn").Value, Integer)
        For i = 1 To DataGridViewIU68E.SelectedRows.Count
            Dim db As New IU68IL33EvaluationDataContext

            Dim ee = From u In db.IU68_IL33_Evaluations _
                     Where u.EvaluationID = ID _
                     Select u
            ee.EmailStatus = "Done"
            db.SubmitChanges()
        Next
    End Sub

I may be wrong, but SelectedRows won't do it for you. SelectedRows is used for rows selected (ie clicked on or multi-selected with Shift or Control pressed while clicking) and not for rows that have been "selected" with a checkbox.

I believe you need to change SelectedRows to Rows and check the value of the checkbox. If the checkbox is checked then do your thing, if not move to the next record.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.