datagridview - DataGridViewRow save data when adding a new row C# -


i have datagridview in win form 2 comboboxcolumns bound each other. when user chooses category first combobox column, values of second 1 filtered.

when add first row code works well, when add new row , value of 1st combobox different 1st row, child combobox of 1st row updated , exception arises.

here code:

      datagridviewcomboboxcolumn speccmb = new datagridviewcomboboxcolumn();             speccmb.headertext = "specification";             speccmb.datasource = specbndsource;             speccmb.displaymember = "specname";             datagridview1.columns.add(speccmb);             sqldataadapter itemadapter = new sqldataadapter("select itemcode, itemname, frgnname, u_index dbo.oitm itemcode 'ae%'", sqlconnection);             itemadapter.fill(dataset, "dtf.dbo.oitm");             datarelation rel = new datarelation("specitem",                  dataset.tables["dtf_medical.dbo.specification"].columns["specid"],                 dataset.tables["dtf.dbo.oitm"].columns["u_index"]);             dataset.relations.add(rel);      datagridviewcomboboxcolumn itemcodecmb = new datagridviewcomboboxcolumn();             bindingsource itembndsource = new bindingsource();             itembndsource.datasource = specbndsource;             itembndsource.datamember = "specitem";             itemcodecmb.headertext = "item code";             itemcodecmb.datasource = itembndsource;             itemcodecmb.displaymember = "itemcode";             itemcodecmb.valuemember = "itemcode";             datagridview1.columns.add(itemcodecmb); 

i need save changes of previous row user adds new one. help,please)


Comments