'counting' alphabetically?

Discussion in 'ASP .Net' started by darrel, Aug 6, 2004.

  1. darrel

    darrel Guest

    I have a userControl that displays a repeaterControl to display data. I have
    this set up so that it pages, 10 records per page.

    This works fine.

    Now, for some of the data, it'd be nice if the end-user could jump to the
    page alphabetically.

    For instance, their may be 80 pages with 10 biographies each. Instead of the
    end user clicking NEXT, NEXT, NEXT until he finds the bio he's looking for
    (let's say Smith, Bob) I'd like for them to be able to click on "s" and jump
    to the particular page where the S's begin.

    Any thoughts on how to do this? Off the top of my head, this is what I'm

    - Grab all records (last name)
    - trim field to first letter
    - Parse all of these to grab only unique letters
    - Attach that to an array
    - Step through the array to write out each letter navigation
    - upon click of 's', query database to grab all records (last name) sorted
    by last name
    - count through the records to get to the first record beginning with 's'/
    - divide by 10
    - redirect to the 10th 'page' of the record set.

    But that seems tedious. Is there a better/more streamlined way?

    darrel, Aug 6, 2004
    1. Advertisements

  2. Datagrid paging is too rude. If you want something other than numbers or
    previous/next, its always a long route. Hopefully MS will address this issue

    Chandra Sekhar, Aug 7, 2004
    1. Advertisements

  3. darrel

    darrel Guest

    If you want something other than numbers or
    Ah...well, I guess I better get comfortable for the long haul. ;o)

    darrel, Aug 9, 2004
  4. darrel

    Scott Allen Guest

    Hi Darrel:

    I was thinking perhaps a different approach would be easier to
    implement (if it meets your requirements).

    Have hyperlinks for each letter of the alphabet available, and instead
    of having them jump to the page, have them filter the records.

    You could do this with the RowFilter property of a DataView object
    (assuming you have a DataSet), or by passing a parameter to use in the
    WHERE clause of your SQL query (but be careful - because this approach
    can reak havoc with the query optimization).

    Scott Allen, Aug 9, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.