Ok, while I'm making sure the next part on the vertical datagrids makes sense I thought I'd drop in a quick bit on databound RSS feeds in asp.net
I'd like to empasise first off this is in no way a method I can take credit for, but I wanted to pass it along to help out any dev's out there who get the fateful brief "oh, before we put this live can you just stick an RSS feed in"
If you've done any reading then you'll know that RSS (Really Simple Syndication) is based around a specific XML format. The key to simple databound RSS is to use a standard page and standard controls, but writing out XML rather than HTML markup.
To make the page work as a feed you need to do the following:
-Delete out all preentered content except for the @Page directive
-In the @Page directive include the attribute ContentType="text/xml"
-Include a standard datasource that will output the data that you want to publish
-Include an asp repeater with the DataSourceID set to your datasource, and with the following content:
HeaderTemplate:
<rss version="2.0">
<channel>
<title>FEED NAME</title>
<link>URL THAT THE FEED WILL BE PUBLISHED TO</link>
<description>DESCRIPTION OF THE FEED</description>
FooterTemplate:
</channel>
</rss>
ItemTemplate:
<item>
<title><%#DataBinder.Eval(Container.DataItem, "POST TITLE COLUMN")%></title>
<description><%#DataBinder.Eval(Container.DataItem, "POST TEXT SUMMARY COLUMN")%></description>
<link>CLICK-THROUGH URL</link>
<pubdate><%#DataBinder.Eval(Container.DataItem, "ARTICLE TIMESTAMP COLUMN")%></pubdate>
</item>
That's all it takes - Enjoy :)
General postings on bits and pieces of ASP.net and other Microsoft development that may be of use out there
Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts
Saturday, 20 November 2010
Tuesday, 26 October 2010
Vertical GridViews in ASP.net - Part 1 : The problem
We've recently been working on a new website that involved a lot of focus on the presentation and layout of product data. In one section specifically data on featured products is displayed side-by-side, but up until now we've been content to have each one individually rendered as a child control, with each subsection of the display just flowing on with a line break, meaning that the data was not truly aligned. In the new site we wanted to improve on this, rendering out in a 'comparison-style' grid.
The obvious web control for this sort of data presentation would be a gridview - they render out as HTML tables, and a lot of standard event hookup code already existed in the codebase for use elsewhere. Here we hit the problem; gridviews render out sequentially with a table row per data item, we wanted it to have a column per data item, and of course HTML tables have no conept of a 'column' of data.
This meant that we needed to find a way of presenting data that:
The obvious web control for this sort of data presentation would be a gridview - they render out as HTML tables, and a lot of standard event hookup code already existed in the codebase for use elsewhere. Here we hit the problem; gridviews render out sequentially with a table row per data item, we wanted it to have a column per data item, and of course HTML tables have no conept of a 'column' of data.
This meant that we needed to find a way of presenting data that:
- rendered each data item vertically
- aligned each section of data horizontally
- used the standard gridview event model
After a considerable amount of research online the general consensus seemed to be to 'hack' the data source to rotate the dataset - crosstab style - or.... give up. Neither of these were really an options so what I'll try and detail in the following posts is how we got the grids as they now appear on the font page of http://public.presalesadvisor.net/
Subscribe to:
Posts (Atom)