c# - DataView.Count() returns more than one value -


i'm kinda new i'll try specific possible.. i'm trying create button that'll display 2 dates in form. i've written this:

dataview dv = new dataview(datacomerciodataset.comex); dv.sort = "id"; int ixe = dv.find(idtextbox.text); datetime embarque = convert.todatetime(dv[ixe]["fechaembarque"]); otherform.fechaembarquedatetimepicker.value = embarque; datetime vencimiento = convert.todatetime(dv[ixe]["fechavencimiento"]); otherform.fechavencimientodatetimepicker.value = vencimiento; otherform.idbox1.text = dv[ixe]["id"].tostring(); this.comextableadapter.fillby3(this.datacomerciodataset.comex, c41textbox.text); 

now, when click button catches exception showing it's dbnull object. decide test adding this:

if (dv.count == 1) {     messagebox.show("1"); } if (dv.count == 0) ; {     messagebox.show("0"); } 

and shows both! since exception states it's dbnull reckon dv.find must returning 0, figure this:

if (ixe == 0) {     ixe = 1;     datetime embarque = convert.todatetime(dv[ixe]["fechaembarque"]);     otherform.fechaembarquedatetimepicker.value = embarque;     datetime vencimiento = convert.todatetime(dv[ixe]["fechavencimiento"]);     otherform.fechavencimientodatetimepicker.value = vencimiento;     otherform.idbox1.text = dv[ixe]["id"].tostring();      this.comextableadapter.fillby3(this.datacomerciodataset.comex, c41textbox.text); } 

but when this, exception index 1 either negative or superior row count (it's in spanish, don't know if that's actual translation) anyway, think i'm not quite getting how dataview.find() indexes result, mean, row 1 = 1 or 0 ?

thanks in advance!

managed work around issue, somehow changing

dataview dv = new dataview(datacomerciodataset.comex); 

to

 dataview dv = new dataview();           dv = datacomerciodataset.comex.asdataview(); 

solved problem, not sure why though...


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -