<p>So, I am kinda new to ASP.net development still, and I already don't like the stock ASP.net controls for displaying my database query results in table format. (I.e. I would much rather handle the HTML myself and so would the designer!)</p>

<p>So my question is: What is the best and most secure practice for doing this without using ASP.net controls? So far my only idea involves populating my query result during the Page_Load event and then exposing a DataTable through a getter to the *.aspx page. From there I think I could just iterate with a foreach loop and craft my table as I see fit.</p>

[{'answer_id': 68556, 'author': 'David J. Sokol', 'author_id': 1390, 'author_profile': 'https://Stackoverflow.com/users/1390', 'pm_score': 3, 'selected': True, 'text': '<p>I believe you\'re looking for a <code>&lt;Repeater&gt;</code> control.  It contains some functionality similar to the GridViews, but allows you hand-craft all of the HTML for the Header, Item, and Footers yourself.  Simply call the databinding code as you would for a gridview, and change the ASPX page to suit your exact HTML needs.</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/magazine/cc163780.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc163780.aspx</a></p>\n'}, {'answer_id': 68568, 'author': 'Tom Ritter', 'author_id': 8435, 'author_profile': 'https://Stackoverflow.com/users/8435', 'pm_score': 2, 'selected': False, 'text': '<p>The successor to the repeater is the <a href="https://web.archive.org/web/20210616112920/https://aspnet.4guysfromrolla.com/articles/010208-1.aspx" rel="nofollow noreferrer">ListView</a>, which will also help you handcraft your HTML.</p>\n'}, {'answer_id': 68582, 'author': 'JamesSugrue', 'author_id': 1075, 'author_profile': 'https://Stackoverflow.com/users/1075', 'pm_score': 1, 'selected': False, 'text': '<p>If you\'re more interested in hand Coding your HTML, it might be worth looking at the <a href="http://www.asp.net/mvc/" rel="nofollow noreferrer">ASP.NET MVC project</a>. You get  a little more control over things than standard WebForms.</p>\n\n<p>As an aside, plugging data access code in the Page_Load is never a good idea. It ties your presentation too much to your data code. Have a look at either the MVC as suggested above which applies a standard design pattern to separate concerns, or do a google search for "ASP.NET nTier" or something similar. It might take a little longer to get a site up and running, but it will save you pain in the long run.</p>\n'}, {'answer_id': 69102, 'author': 'Steven A. Lowe', 'author_id': 9345, 'author_profile': 'https://Stackoverflow.com/users/9345', 'pm_score': 1, 'selected': False, 'text': "<p>three options:</p>\n\n<ol>\n<li><p>learn to use the existing controls like GridView; with proper CSS they can look quite nice, since they just generate HTML on the client side</p></li>\n<li><p>generate your HTML using templates or StringBuilder and put it in a Literal control on your web page</p></li>\n<li><p>buy a third-party library that has controls that you do like</p></li>\n</ol>\n\n<p>number 1 is the 'best' option for asp.net in the long term because you will actually master the controls that everyone else uses; option 2 is tedious; option 3 is a quick fix and may be expensive</p>\n"}]
['https://Stackoverflow.com/questions/68543', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/506/']