I have a few questions concerning populating a table from a datatable in asp.net
I have pulled data correctly from my database but now I have a table with data in it. How do I go about populating my asp.net Table control? I understand how to access the rows and columns data but don't know how to "bind" or "populate" the Table control.
I looked into using a gridview but some people said they load slow so I am avoiding that.
Any help would be much appreciated
HTML
<asp:Table runat="server" ID="table" CssClass="table">
<asp:TableHeaderRow>
<asp:TableCell>Cell 1 Header</asp:TableCell>
<asp:TableCell>Cell 2 Header</asp:TableCell>
</asp:TableHeaderRow>
<asp:TableRow>
<asp:TableCell ID="cell1"></asp:TableCell>
<asp:TableCell ID="cell2"></asp:TableCell>
</asp:TableRow>
</asp:Table>
C#
String sql = "SELECT * FROM TABLE";
SqlCommand command = new SqlCommand(sql, dbConnection);
SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
DataTable table = dataSet.Tables[0];
// Loop through rows
foreach (DataRow row in table.Rows)
{
// Loop through columns
foreach(DataColumn column in table.Columns){
}
}