Home All Groups Group Topic Archive Search About

Data-Based User Controls

Author
11 Oct 2006 6:41 PM
Jonathan Wood
I'm new to C# and ASP.NET, and wondered if anyone could give me some
pointers on this.

I want a serious of boxes on the left side of my master page. Each box will
display a graphic image followed by any number of links. Each box needs to
correspond to a category in a database. So the number of boxes is not known
in advance.

In addition, the links displayed in each box will be the items in that
category. So the number of links is not known in advance. I'd also like to
display a little message when there are no links for that category.

Does this seem a reasonably efficient way to approach this?

Any tips or code snippets?

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

Author
12 Oct 2006 1:36 PM
Patrick Steele
In article <e#57dSW7GHA.4***@TK2MSFTNGP02.phx.gbl>,
jw***@softcircuits.com says...
> I'm new to C# and ASP.NET, and wondered if anyone could give me some
> pointers on this.
>
> I want a serious of boxes on the left side of my master page. Each box will
> display a graphic image followed by any number of links. Each box needs to
> correspond to a category in a database. So the number of boxes is not known
> in advance.
>
> In addition, the links displayed in each box will be the items in that
> category. So the number of links is not known in advance. I'd also like to
> display a little message when there are no links for that category.
>
> Does this seem a reasonably efficient way to approach this?

First off, I would consider designing a user control that represents
this collection of links.  Then your master page simply needs this one
user control and it simplifies things when you want to tweak your master
page layout.

Getting the data from the database is pretty easy.  I assume you've got
two different tables -- one for 'categories' and one for
'categorylinks'.  You could load both the 'category' table and the
'categorylinks' table into a DataSet and then set up a DataRelation on
their foreign keys.  You can easily loop through the main 'category'
table, create your box and then populate the box from the
'categorylinks' table for the particular category.

Finally, do some research on caching since (I assume) your list of
categories/link won't change too often.  By caching the user control,
you can prevent the need to hit the database and read the collection of
categories/links every time a page is accessed.

Hope this helps -- and take it all with a grain of salt.  I've only done
a little bit of ASP.NET 2.0 work.  :)  Most of the ASP.NET stuff I did
was 1.x.


AddThis Social Bookmark Button