c# - Insert empty value from datagridview -


I am trying to insert the empty amount from the dotgrid view when the cell is left empty, this is what I I am:

 using  (var reference = new employee attitudes) {EMPLOYEE emp = new EMPLOYEE (); Foreach (DataGridViewRow line in dgvLoadTable.Rows) {If (row.Cells [0] .Value! = Null) {emp.EMP_ID = int.Parse (row.Cells [0] .Value.ToString ()); Emp.DEPARTMENT = row.Cells [2]. Value is DBNull? String Empty: line. Seals [2] Value Toasting (); // Also tried: emp.DEPARTMENT = Row Seals [2] Value is DBNull? DBNull.Value.ToString (): row.Cells [2] .Value.ToString (); Context.EMPLOYEE.AddObject (EMP); Context.SaveChanges (); }}}  

but it is not working, when I try to include zero value, it throws it "the object is not set for the example of reference object "Exception what am I doing wrong here?


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -