Reputation: 143
I have an aspx page which contains a 3-page multiview. On the second page I have a asp:listview which allows me to insert/update/delete into a DataTable which I have defined in my aspx.cs file.
This all works fine. I am able to insert into the table and display what is inserted into a table on the webpage just below the insert form.
My question is as follows:
I would like to be able to loop through the table on the 3rd page in the multiview and display the contents stored in the table. How do I "send" the DataTable over to the aspx page?
I imagine that the looping code would be similar to this:
<table border="0">
<tr>
<% for( var col in Model.Columns ) { %>
<th><%= col.ColumnName %>
<% } %>
</tr>
<% for( var row in Model.Rows ) { %>
<tr>
<% for( var col in Model.Columns ) { %>
<td><%= row[col].ToString() %></td>
<% } %>
</tr>
<% } %>
</table>
Upvotes: 0
Views: 1213
Reputation: 3098
You could have an
<asp:Gridview id="gvMyData" runat="server" AutoGenerateColumns="True" />
Then in your code behind, just bind your datatable to it.
gvMyData.DataSource = myDataTable;
gvMyData.DabaBind();
Upvotes: 2