uitableview - Retrieving Multiple rows from SQLite in Xamarin iOS -
i'm doing app xamarin ios. put uitableview
on xcode, when click on button, retrieves database , slot in. i'm able put onto row, couldn't figure out how have multiple rows of data in it. partial code i'm able display row of data.
cmd.commandtype = commandtype.text; dr = cmd.executereader(); while (dr.read()) { var table = new uitableview(this.retrievedata.frame); string[] tableitems = new string[] {dr["admin_num"] + ", " + dr["name"]}; table.source = new tablesource(tableitems); add (table); }
you creating new tableview each row in data. instead, should loop through data , create data structure (list, array, etc) containing of data want display, , pass data tableview/source.
cmd.commandtype = commandtype.text; dr = cmd.executereader(); // need class mydata num , name properties list<mydata> data = new list<mydata>(); while (dr.read()) { data.add(new mydata { num = dr["admin_num"], name = dr["name"] }); } dr.close(); var table = new uitableview(this.retrievedata.frame); table.source = new tablesource(data); add (table);
Comments
Post a Comment