c# - Passing fields from a table into a Model -


i have method pass data datagridview model:

for (rows = 0; rows < cview.datagridview1.rows.count; rows++) {     if (cview.datagridview1.rows[rows].cells[col].value != null)     {         // creates model, populates each field cells in table.         smodel = new supplierid_model();         smodel.xsec = convert.todouble(cview.datagridview1.rows[rows].cells[0].value);         smodel.insulation = convert.tostring(cview.datagridview1.rows[rows].cells[1].value);         // etc...         // passes model database.     }     else     {         // passes empty fields dummy variables avoid null entries in db.         supppartno = string.empty;         xsec = string.empty;         insul = string.empty;         // etc...     } } 

i know issue in specific instance have 2 empty lines @ bottom of datagridview, causing else not implemented properly. comes smodel.xsec = convert.todouble... , says "input string not in correct format".

edit: have tried while loop, gets caught on last entry starts 0 , continues looping. continues enter same values indefinitely, without entering rest of table.

is there better way allow more errors (empty fields)?


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -