Click here to Skip to main content
12,243,752 members (43,479 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB 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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2016
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