system.form exeception data gridview combobox cell while inserting data to data grid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaseem0712
    New Member
    • Jun 2013
    • 7

    #1

    system.form exeception data gridview combobox cell while inserting data to data grid

    I have a data grid view,,in third column of data grid view is combox box,,am filling thise
    Code:
     Dim c As DataGridViewComboBoxColumn
                Dim cmd2 As New SqlCommand("select desigID,DName from Designation_tbl where deleted=0", con.connect)
                cmd2.CommandType = CommandType.Text
                Dim objdataadapter As New SqlDataAdapter(cmd2)
                Dim results As New DataSet
        
                objdataadapter.Fill(results, "DesignationMaster_tbl")
                c = DGVEmployee.Columns(3)
                c.DataSource = results.Tables("DesignationMaster_tbl")
                c.ValueMember = "desigID"
                c.DisplayMember = "DName"
                con.disconnect()
    after that i want to fill my data grid view..
    so i manually created all columns..
    then i wrote code like this:
    Code:
    Dim Ecode As String
                Dim Ename As String
                Dim email As String
                Dim design As String
        Dim cmd As New SqlCommand("  select eCode,eName,desigID from EmployeeMaster_tbl", con.connect)
         dr = cmd.ExecuteReader
                While dr.Read
                    If dr("eCode") Is DBNull.Value Then
                        Ecode = ""
                    Else
                        Ecode = dr("eCode")
                    End If
                    If dr("eName") Is DBNull.Value Then
                        Ename = ""
        
                    Else
                        Ename = dr("eName")
        
                    End If
                    If dr("desigID") Is DBNull.Value Then
                        design = ""
                    Else
                        design = dr("desigID")
                        desgnationname = RecordID_String("DName", "Designation_tbl", "desigID", design)
        
                    End If
         Dim row0 As String() = {Ecode, Ename, email, desgnationname}
        DGVEmployee.Rows.Add(row0)
          End While
    but am getting error: system.form exeception data gridview combobox cell
Working...