By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 897 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

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

P: 7
I have a data grid view,,in third column of data grid view is combox box,,am filling thise
Expand|Select|Wrap|Line Numbers
  1.  Dim c As DataGridViewComboBoxColumn
  2.             Dim cmd2 As New SqlCommand("select desigID,DName from Designation_tbl where deleted=0", con.connect)
  3.             cmd2.CommandType = CommandType.Text
  4.             Dim objdataadapter As New SqlDataAdapter(cmd2)
  5.             Dim results As New DataSet
  6.  
  7.             objdataadapter.Fill(results, "DesignationMaster_tbl")
  8.             c = DGVEmployee.Columns(3)
  9.             c.DataSource = results.Tables("DesignationMaster_tbl")
  10.             c.ValueMember = "desigID"
  11.             c.DisplayMember = "DName"
  12.             con.disconnect()
after that i want to fill my data grid view..
so i manually created all columns..
then i wrote code like this:
Expand|Select|Wrap|Line Numbers
  1. Dim Ecode As String
  2.             Dim Ename As String
  3.             Dim email As String
  4.             Dim design As String
  5.     Dim cmd As New SqlCommand("  select eCode,eName,desigID from EmployeeMaster_tbl", con.connect)
  6.      dr = cmd.ExecuteReader
  7.             While dr.Read
  8.                 If dr("eCode") Is DBNull.Value Then
  9.                     Ecode = ""
  10.                 Else
  11.                     Ecode = dr("eCode")
  12.                 End If
  13.                 If dr("eName") Is DBNull.Value Then
  14.                     Ename = ""
  15.  
  16.                 Else
  17.                     Ename = dr("eName")
  18.  
  19.                 End If
  20.                 If dr("desigID") Is DBNull.Value Then
  21.                     design = ""
  22.                 Else
  23.                     design = dr("desigID")
  24.                     desgnationname = RecordID_String("DName", "Designation_tbl", "desigID", design)
  25.  
  26.                 End If
  27.      Dim row0 As String() = {Ecode, Ename, email, desgnationname}
  28.     DGVEmployee.Rows.Add(row0)
  29.       End While
but am getting error: system.form exeception data gridview combobox cell
Feb 4 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.