c# - Unable to cast object of type 'System.Collections.ArrayList' to type 'System.IConvertible' -



c# - Unable to cast object of type 'System.Collections.ArrayList' to type 'System.IConvertible' -

i have count of rows based null value on 1 specific column. have used given below code. here cad assign column contains values , null values. have count how many null values on cad_assign, , based on have display values.

protected void ddlcircle_selectedindexchanged(object sender, eventargs e) { arraylist list = new arraylist(); shadinganalysisdatasettableadapters.tbl_cadengineersteamtableadapter cd; cd = new shadinganalysisdatasettableadapters.tbl_cadengineersteamtableadapter(); datatable dt = new datatable(); dt = cd.getavailabledata(ddlcircle.selectedvalue);// dt values cad_assign null int x; foreach (datarow dtrow in dt.rows) { list.add(dtrow); // here getting dt count. } x = convert.toint32(list); // error popup here }

sql query:

select state1, district, site_id, site_name tbl_site_details (state1 = @state1) , (cad_assign null)

your current problem you're trying convert arraylist int32 (convert.toint32 doesn't count list, tries convert given object integer).

if you're trying count list, can utilize arraylist.count:

x = list.count;

you can take 1 step easier , not utilize list , straight take count of rows:

x = dt.rows.count;

or improve alter sql homecoming count directly:

select count(1) tbl_site_details (state1 = @state1) , (cad_assign null)

i'm not sure how fetch scalar result using shadinganalysisdatasettableadapters, should able @ least:

var x = (int)dt.rows[0][0];

c# asp.net

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -