Wednesday, 15 January 2014

c# - Output Data from DataAdapter to HTML Table -



c# - Output Data from DataAdapter to HTML Table -

the next code seems generate dataadapter:

protected void grdmain_databind() { dbproviderfactory dbf = dbproviderfactories.getfactory(); using (idbconnection con = dbf.createconnection()) { string ssql; ssql = "select * , " + controlchars.crlf + " case isnull((select top 1 email_id emails_attachments attachment_id=vwfiles_attachments.attachment_id),'00000000-0000-0000-0000-000000000000') " + controlchars.crlf + " when '00000000-0000-0000-0000-000000000000' '0' else '1' end sent_attachment " + controlchars.crlf + " , case file_ext when '.pdf' 'true' else 'false' end 'enablecheck'" + controlchars.crlf + " , case visible_to_client when '1' '" + session["themeurl"].tostring() + "images/check_inline.gif'" + controlchars.crlf + " else '" + session["themeurl"].tostring() + "images/close_inline.gif' " + controlchars.crlf + " end 'visible_to_client_path'" + controlchars.crlf + " vwfiles_attachments" + controlchars.crlf + " 1 = 1 " + controlchars.crlf; using (idbcommand cmd = con.createcommand()) { seek { using (dbdataadapter da = dbf.createdataadapter()) { ((idbdataadapter)da).selectcommand = cmd; using (datatable dt = new datatable()) { da.fill(dt); vwmain = dt.defaultview; grdmain.datasource = vwmain; // 09/05/2005 paul. linkbutton controls not fire event unless the grid bound. if (!ispostback) { //grdmain.sortcolumn = "date_entered"; //grdmain.sortorder = "desc"; //grdmain.applysort(); } grdmain.databind(); } } } grab (exception ex) { splendiderror.systemerror(new stacktrace(true).getframe(0), ex.message); } } } }

how output info html table? have tried next error says 'dt' not exist in current context:

<% foreach (datarow row in dt.rows) { %> <!-- loop through list --> <div> <%= row.id %> <!-- write out name of site --> </div> <% } %> <!--end loop -->

c# asp.net webforms

No comments:

Post a Comment