public static void dropdownlist_bind(dropdownlist list_name,string dtatxtfield,string datavaluefield,string procedure) { openconnection(); com = new sqlcommand(procedure, con); com.commandtype = commandtype.storedprocedure; sqldatareader dtr = com.executereader(); list_name.datasource = dtr; list_name.datatextfield = dtatxtfield; list_name.datavaluefield = datavaluefield; list_name.databind(); dtr.close(); closeconnection(); } public static void openconnection() { if(con.state==connectionstate.closed) con.open(); } public static void closeconnection() { if (con.state == connectionstate.open) con.close(); }
this bussiness logic code binding dropdownlist,it giving execption there open datareader associated command must closed first. on sqldatareader dtr = com.executereader();
.please give suggestions. thanx in advance
you need make “multipleactiveresultsets=true” in connection string.
i have written blog post @ following link.
regards,
Comments
Post a Comment