datagrid/list vs. roll-your-own ASP templates?

D

darrel

I'm new to ASP in general. Have been doing a bunch of stuff using classic
ASP and a bit of stuff with ASP.NET (all with VBscript).

The .NET stuff i've been doing has been fairly simple...generating a report
from an Access table. The Datagrid along with some TemplateColumns seemed to
work well for that.

I'm not needing to now pull data from our Homemade CMS database to present
on our public site.

Datagrids and lists don't seem appropriate for this. They seem great for
whipping out quick data views, but seem really limited when it comes to
tweaking the display to include CSS, accessibility tags and attributes, and
formatting.

I need to spit out some content in this format:

[get the last 4 items from the newsitem table and use the template below]

<div class="newsitem">
<span class="date">[get the date and put it here]</span>
<h3>[get the date]</h3>
<p>[get the first 40 words]</p>
<p class="moreLink"><a>View More</a></p>
</div>

When I need something like this, are there any server controls I should look
at, or should I forget that and just go back to using inline ASP if/then
loops with a lot of response.write's to generate the wrapping HTML?

Actually, to simplify the question:

When should I use server controls vs. hand-rolled ASP templates?

-Darrel
 
B

Bin Song

Try Repeater Web server control.
The Repeater Web server control is a data-bound container
control that produces a list of individual items. You
define the layout of individual items on a Web page using
templates.
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpgenref/html/cpconrepeaterwebservercontrol.asp

Bin Song, MCP
 
S

Scott

I battle with this alot myself and am by no means a master of this, but I
can tell you some things that I know (also being an old ASP/VB programer
since 4.0 :) )

For attaching style sheets to a grid control, look around for the cssclass
command of the control (<asp:datagrid cssclass=<name>>). This will allow
you to get the look that you want by attaching CSS files to your grids.

If you really want to 'take it up a notch', think about using XML/XSL and
other related technologies to do your pages. If you get the huge MS-Press
book on XML they go through everything you need to know in there. But be
warned: it is not for the newbies and took me months to figure out how to
put it all together to build an app. Also, I am still having problems with
the XML techniques when it comes to the display of certain data in the grids
(ie. appostrofies in names and other special characters). Also, I found an
XML solution to be harder to support because of the extra levels that need
to be worked out, which adds complication to the app. The programmers that
I work with are less experienced than I am and they can never troublshoot
the XML stuff because it is too complex for them to follow. This creates
great job security, but also alot of headaches because I am the only one
that can work on certain apps.

I hope this helps. Maybe others have ideas too. All the best to you!

Scott
 
D

darrel

For attaching style sheets to a grid control, look around for the cssclass
command of the control (<asp:datagrid cssclass=<name>>). This will allow
you to get the look that you want by attaching CSS files to your grids.

But isn't a grid inherently a table? That's one of the problems I'm finding.
I'm really trying to move our site towards less tables and more CSS for a
variety of reasons. ASP.NET seems to be a bit of a hindrance in that regard.
If you really want to 'take it up a notch', think about using XML/XSL and
other related technologies to do your pages.

Yea, that's probably taking it up too many notches for now ;o)
This creates
great job security, but also alot of headaches because I am the only one
that can work on certain apps.

Ha! Yea, that's a tough one ;o)
I hope this helps. Maybe others have ideas too. All the best to you!

And thanks for the info!

-Darrel
 
D

darrel

Try Repeater Web server control.

Hmm...that looks promising. Thanks for the info on that...off to read for a
bit!...

-Darrel
 
M

Mark

The other guys' reponses are good ones ... here is yet another option to
consider. I use the classes below instead of Response.Write("my html goes
here"); .... works pretty well. I don't use css much but I imagine it can
be incorporated as you might hope it does.

HtmlTable class
HtmlTableRowCollection
HtmlTableRow
HtmlTableCell

Then add these to a PlaceHolder control or similar on your page.

HTH,
mark
www.dovetaildatabases.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top