Reputation: 97
I have a very large finance table, which will be repeated 4 times on a page, across many different pages on the website.
I don't like the idea of just copying the table 4 times on a page. So I want to call it in once, probably using a control. And then populate the tables four times, loading in set values define in the .cs backend. ?
a) Can this be done?
b) I've read articles on repeaters, datatables, grids, can anybody how me the direct I need to be taking please?
<div id="finance-boxes" class="span3">
<table class="table">
<tr><th>36 month PCP</th></tr>
<tr><td colspan="2"><img src="/images/1" alt="Mitsubishi Mirage PCP" /></td></tr>
<tr><td class="title">On The Road Price <span>(inc. Vat)</span></td></tr>
<tr><td class="fig">£129.00</td></tr>
<tr><td class="title">Deposit</td></tr>
<tr><td class="fig">£2,514</td></tr>
<tr><td class="title">Monthly Payment</td></tr>
<tr><td class="fig">£129.00</td></tr>
<tr><td class="title">Representative APR</td></tr>
<tr><td class="fig">6.7%</td></tr>
<tr><td class="title">Duration of Agrement</td></tr>
<tr><td class="fig">36 months</td></tr>
<tr><td><a href="#financeDetail36" role="button" class="btn btn-danger" data-toggle="modal">Launch Finance Details</a></td></tr>
</table>
Upvotes: 0
Views: 651
Reputation: 498
Have you considered putting this into a new UserControl? You could have an enum for the four different types of data to load, have a public property to specify the enum, drop the UserControl wherever you need the table, and then specify the property in the markup, so it knows which data to load. UserControls are one of the simplest way to reuse in webforms.
Upvotes: 1