'counting' alphabetically?

  • Thread starter Thread starter darrel
  • Start date Start date
D

darrel

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
thinking:

- 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
 
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
soon.

Sekhar.
 
If you want something other than numbers or
previous/next, its always a long route.

Ah...well, I guess I better get comfortable for the long haul. ;o)

-Darrel
 
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).

HTH,
 
Back
Top