Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

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

$
0
0
I have a data grid view,,in third column of data grid view is combox box,,am filling thise

 
  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:
   

   
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





Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>