create a div dynamically for every row in database table ASP.Net -
i'm designing website fyp, have customerorder page, , vieworders page, customer places order in customerorder page. in vieworders want display result of sql query, in dynamically created "div" , "labels" css assigned them each row of table, in following sqldatareader.tnx
protected void page_load(object sender, eventargs e) { string localcnnstring = configurationmanager.connectionstrings["lgdb"].tostring(); sqlconnection sqlcnn = new sqlconnection(localcnnstring); sqlcommand sqlcmd = new sqlcommand(); sqldatareader dreader; sqlcnn.open(); sqlcmd.connection = sqlcnn; sqlcmd.commandtype = commandtype.storedprocedure; sqlcmd.commandtext = "myrpoc"; dreader = sqlcmd.executereader(); while (dreader.read()) { //dynamic controls } dreader.close(); sqlcnn.close(); } }
this scenario can solved in many different ways. general approach though sort of data binding. if you're doing web forms repeater control, offer template based data binding.
a less elegant way loop out dynamic html.
Comments
Post a Comment