Click here to Skip to main content
11,496,146 members (624 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: VB.NET
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 23-Dec-12 20:11pm
Edited 23-Dec-12 20:12pm
v2

1 solution

  Permalink  
Comments
Rachna0309 at 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)

  Print Answers RSS
0 RyanDev 230
1 Sergey Alexandrovich Kryukov 114
2 Richard Deeming 100
3 OriginalGriff 89
4 Mostafa Asaduzzaman 59
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100