How can I build a user control with same look but different set of data?

Q

Quentin Huo

Hi:

I want to create a user control to render the top 10 list, which may be top
10 authors or top 10 books, or .... And it will be cached by "VaryByParam".

The UC looks same what the data is, like:

1. item1
2. item2
.......
10 item10

My question is in the code-behind: the data for different ranks come from
different tables, so I have to use "if" statement in the code-behind, like:

if(isAuthorList)
findAuthorRank...
else if(isBookList)
findBookRank...
.......

The problem is: if someday, I want to use new data to it, for example: top
10 Company, I have to modify the code-behind, is there any good solution for
it so that I don't need to modify the code-behind? Is there any design
pattern for it?

If not, any other idea?

Thanks

Q.
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top