Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have datagridview which contains 12 columns.Last 3 columns are caste,prof,degree and these are comboboxcolumn. I am changing these comboboxcolumn values to save it into database.
On cellvalue changed event,I am writing following code:
If e.ColumnIndex = 9 Then
            If Me.dgvUserDetails.Rows(e.RowIndex).Cells(9).Value.ToString <> "" Then
                caste = Me.dgvUserDetails.Rows(e.RowIndex).Cells(9).Value.ToString
                sql = "Select ID from Category where Desc = '" & caste & "'"
                If rs.State = 1 Then rs.Close()
                rs.Open(sql, MainCon, 1, 3)
                If Not rs.EOF Then
                    C_Id = rs.Fields(0).Value
                End If
                
            End If
        ElseIf e.ColumnIndex = 10 Then
            If Me.dgvUserDetails.Rows(e.RowIndex).Cells(10).Value.ToString <> "" Then
                prof = Me.dgvUserDetails.Rows(e.RowIndex).Cells(10).Value.ToString
                sql = "Select ID from Category where Desc = '" & prof & "'"
                If rs.State = 1 Then rs.Close()
                rs.Open(sql, MainCon, 1, 3)
                If Not rs.EOF Then
                    P_Id = rs.Fields(0).Value
                End If
               
            End If
        ElseIf e.ColumnIndex = 11 Then
            If Me.dgvUserDetails.Rows(e.RowIndex).Cells(11).Value.ToString <> "" Then
                degree = Me.dgvUserDetails.Rows(e.RowIndex).Cells(11).Value.ToString
                sql = "Select ID from Category where Desc = '" & degree & "'"
                If rs.State = 1 Then rs.Close()
                rs.Open(sql, MainCon, 1, 3)
                If Not rs.EOF Then
                    D_Id = rs.Fields(0).Value
                End If
                
            End If
        End If


I want to use for loop to move to next row.How to use it?
Posted
Updated 23-Dec-12 19:12pm
v2

1 solution

 
Share this answer
 
Comments
Rachna0309 24-Dec-12 1:19am    
I have already tried this code but what I want is after I select in caste column,it should move to prof column then to degree but its not going.

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