c# - datatable turns empty when i pass it to method -
so have simple function goes through table , find rows has age columns between 2 numbers , return new table new rows. here function :
private datatable agefinder(int miniage, int maxiage, datatable x) { //afwt : analyze table int count; datatable dtage = new datatable(); dtage = x.clone(); int agemin = miniage; int agemax = maxiage; if (agemin > agemax) { int temp = agemax; agemax = agemin; agemin = temp; } int agedr; count = 0; agedr = 0; datagridview1.datasource = x; foreach (datarow dr in x.rows) { agedr = convert.toint16(x.rows[count]["age "]); if (agedr >= agemin && agedr < agemax) { dtage.rows.add(dr.itemarray); } count++; } lblcountthisquery.text = dtage.rows.count.tostring(); return dtage; }
and here how call it:
dtage = agefinder(convert.toint16(tbxminage.text), convert.toint16(tbxmaxage.text), at); datagridview1.datasource = dtage;
now can see @ not empty when check x (the table inside method), empty! why happen?
Comments
Post a Comment