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

Discussion in 'ASP .Net Building Controls' started by Quentin Huo, Aug 6, 2004.

  1. Quentin Huo

    Quentin Huo Guest

    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.
     
    Quentin Huo, Aug 6, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexander N. Spitzer
    Replies:
    21
    Views:
    1,786
    Randolf Richardson
    Aug 16, 2004
  2. Christopher Brewster
    Replies:
    5
    Views:
    349
    John Machin
    Nov 14, 2008
  3. bluebaron
    Replies:
    3
    Views:
    754
    Jonathan N. Little
    Nov 4, 2009
  4. Guest
    Replies:
    2
    Views:
    185
    Foo Man Chew
    Dec 29, 2003
  5. Replies:
    4
    Views:
    179
Loading...

Share This Page