c# - How to display data into <table> tag using datatable? -
hello doing web project in vs express web , quite new c# programming , adjusting syntax , format of it. wandering how display data in datatable , display in table web page when button1_click triggered:
when click button data:
<button type="button" runat="server" onserverclick="button1_click" id="searchinfo" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> search info</button>
and display in table made: using code behind (aspx.cs) controls of web page , made far:
using mssqlconnector; using system; using system.collections.generic; using system.data; using system.data.sqlclient; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; namespace webapplication1.eyeofheaven { public partial class searchcustomer : system.web.ui.page { protected void page_load(object sender, eventargs e) { } protected void button1_click(object sender, eventargs e) { dataset selectedangels = connector.executequery("select * customer idcustomer = 453433"); datatable dt = selectedangels.tables[0]; } } }
use data controls gridview.
add following markup in .aspx page
<asp:gridview runat="server" id="data"/>
code in click handler.
protected void button1_click(object sender, eventargs e) { msconnector connector = new msconnector(); connector.connectionstring = "server=xbetasql,52292;uid=username;password=secret;database=atdbsql;"; dataset selectedangels = connector.executequery("select * customer idcustomer = 453433"); datatable dt = selectedangels.tables[0]; data.datasource = dt; data.databind(); }
Comments
Post a Comment