Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

I had a problem with updating only the checked rows in GridView. I need to update one column cell value based on the ID value of the Checked rows only

What I have tried:

I tried this code but it update random rows, not the checked, can you please help me solve this issue?
VB
Try
    Dim I As Integer
    For I = 0 To GridView1.SelectedRowsCount() - 1
        If (GridView1.GetSelectedRows()(I) >= 0) Then
            Dim strID As String = GridView1.GetRowCellValue(I, "ID")
            Dim strUpdate As String = "UPDATE records SET payment_order= @payment_order where ID = @ID"
            cmd.CommandType = CommandType.Text
            cmd.CommandText = strUpdate.ToString()
            cmd.Parameters.Clear()
           
            cmd.Parameters.AddWithValue("@payment_order", rfnd_id_lbl.Text)
            cmd.Parameters.AddWithValue("@ID", strID)
            cmd.Connection = con
            con.Open()
            cmd.ExecuteNonQuery()
        End If
    Next

Catch ex As SqlException
    Dim errorMsg As String = "Error in Update"
    errorMsg += ex.Message
    Throw New Exception(errorMsg)
Finally
    con.Close()
End Try
Posted
Updated 26-Mar-17 7:35am
v2

1 solution

 
Share this answer
 
Comments
Member 13022818 26-Mar-17 13:53pm    
I got this Error

Error 35 'Rows' is not a member of 'DevExpress.XtraGrid.Views.Grid.GridView'.
That means you are using DevExpress Grid not Asp.Net Grid. So, find out what is the similar thing in DevExpress.

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