i have listview control displays data has 12 columns. column 1 9 displays, above 9 doesn't displays data index number provided.
check out bellow code has indexes display columns. see above pic:
public void populateproductlist() { string cmdstring = "select * product"; stockdbconnection dbcon = new stockdbconnection(); sqlceconnection conn = new sqlceconnection(dbcon.returnconnection("connstring")); sqlcecommand cmd = new sqlcecommand(cmdstring, conn); try { conn.open(); sqlcedatareader dr = cmd.executereader(); lstvwproduct.items.clear(); while(dr.read()) { listviewitem obj=new listviewitem(); obj.subitems[0].text = dr[0].tostring(); obj.subitems.add(dr[1].tostring()); obj.subitems.add(dr[2].tostring()); obj.subitems.add(dr[3].tostring()); obj.subitems.add(dr[4].tostring()); obj.subitems.add(dr[5].tostring()); obj.subitems.add(dr[6].tostring()); obj.subitems.add(dr[7].tostring()); obj.subitems.add(dr[8].tostring()); obj.subitems.add(dr[9].tostring()); obj.subitems.add(dr[10].tostring()); obj.subitems.add(dr[11].tostring()); //in object of listviewitem give display member @ first , give value member @ second position lstvwproduct.items.add(obj); // add object listbox } } catch (exception exp) { messagebox.show(exp.message); } } the problem is: index 10 , 11 doesn't display, have column collection them.
you try assigning dataset gridview's datasource property. more helpful you.
public void populateproductlist() { string cmdstring = "select * product"; stockdbconnection dbcon = new stockdbconnection(); sqlceconnection conn = new sqlceconnection(dbcon.returnconnection("connstring")); sqlcecommand cmd = new sqlcecommand(cmdstring, conn); dataset ds; try { conn.open(); sqlcedataadapter da = new sqlcedataadapter(cmdstring, conn); da.fill(ds); lstdgview.datasource=ds; } catch (exception exp) { messagebox.show(exp.message); } }
Comments
Post a Comment