c# - Why DataBinding doesn't work on second time around? -
my code below search record in excel based on textbox text , bind datagrid. if tried searching same value , bind again got error " databinding cannot find row in list suitable bindings." idea how reset binding ? tries formattingenables set true didn't work. thank you
oledbconnection connexcel = new oledbconnection(_econnect); cmdexcel.connection = connexcel; connexcel.open(); datatable dt; dataset ds = new dataset(); dt = connexcel.getoledbschematable(oledbschemaguid.tables, null); oledbdataadapter da = new oledbdataadapter(); string sheetname = "badgeid$"; cmdexcel.commandtext = "select id, name, dept [" + sheetname + "] id in (" + sss +")"; da.selectcommand = cmdexcel; da.fill(ds); connexcel.close(); bsdata .datasource = ds.tables [0]; //error here invoke(new methodinvoker(() => textbox1.databindings.add("text", bsdata, "name"))); invoke(new methodinvoker(() => textbox2.databindings.add("text", bsdata, "dept")));
call databindings.clear() each of textbox
Comments
Post a Comment