c# - LinQ datasource showing this error "LinqDataSource 'AirAsiaDC' has no values to insert. Check that the 'values' dictionary contains values" -


here trying do, using linq data context insert new record database, reason, linq showing error "linqdatasource 'airasiadc' has no values insert. check 'values' dictionary contains values." weird part, when check record tried insert before, there. wrong here?

by way, here code :

protected void detailsview1_itemcommand(object sender,                                          detailsviewcommandeventargs e) {     airasiadcdatacontext linq = new airasiadcdatacontext();      try     {         if (e.commandname == "edit")         {             textbox tbname = (textbox)detailsview1.findcontrol("deptname");             department dpt;              if ((tbname.text != null) && (tbname.text != ""))             {                 dpt = linq.departments.single(d => d.departmentcode == code);                 dpt.departmentname = tbname.text;                 dpt.updateby = "hendra";                 dpt.lastupdate = datetime.now;                 linq.submitchanges();                 response.redirect("department.aspx");             }             else             {                 diverror.visible = true;                 lblerror.text = "department name can not empty";             }         }         else if (e.commandname == "insert")         {             textbox tbcode = (textbox)detailsview1.findcontrol("deptcode");             textbox tbname = (textbox)detailsview1.findcontrol("deptname");             department dpt = new department();              if (((tbcode.text != null) && (tbcode.text != ""))               && ((tbname.text != null) && (tbname.text != "")))             {                 dpt.departmentcode = tbcode.text;                 dpt.departmentname = tbname.text;                 dpt.createby = "hendra";                 dpt.createdate = datetime.now;                 dpt.updateby = "hendra";                 dpt.lastupdate = datetime.now;                 linq.departments.insertonsubmit(dpt);                 linq.submitchanges();             }             else if ((tbcode.text == null) || (tbcode.text == ""))             {                 diverror.visible = true;                 lblerror.text = "department code can not empty";             }             else if ((tbname.text == null) || (tbname.text == ""))             {                 diverror.visible = true;                 lblerror.text = "department name can not empty";             }         }     }     catch (exception ex)     {         diverror.visible = true;         lblerror.text = ex.message.tostring();     } } 

i try use try , catch nothing, , linq keep on showing error , throw me error screen.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -