So I am trying to create an a to z directory from a list of items which should be an easy task and it is really, however, I am trying to find the most efficient way of doing it.

So I was thinking use querystring as a filter value and then loop through, outputting the items where the first letter matches the letter that is specified in the querystring.

This works, yay! But i know it is inefficient, I shoup be querying the list for all items that have the first letter and then displaying them.

Anyone know a good way to do this, even pseudo code is fine, i am not expecting anyone to do this for me just pointing in the right direction would be good.

For clarification, I want to create this in code, no code solutions are no good here as there is other stuff going on too.



I am going to cover a few things as I don't know exactly what you're doing here.

  1. Create a calculated column to display the first letter of your field using formula - lets call this "FirstLetter"


  2. Optionally, you can then use the Group By feature to show a collapsed/expanded list on [FirstLetter] - (see "The By Last Name View" here for an example)

  3. You can then filter on your First Letter using the normal List View filtering operation.

  4. Additionally you could add a filter provider web part (built in if using MOSS/2010 Server) or lots of 3rd part web parts about.

  5. Or you can make use of filtering via the query sting - e.g. you put on end of url


    and this will apply the X filter.

So you can build up a a 'chooser' by adding something like the following HTML to a Content Editor Web Part (CEWP) or source in wiki.

<a href="/yoursite/yourpage.aspx?FilterField1=FirstLetter&FilterValue1=A">A</a> |
<a href="/yoursite/yourpage.aspx?FilterField1=FirstLetter&FilterValue1=B">B</a> |
<a href="/yoursite/yourpage.aspx?FilterField1=FirstLetter&FilterValue1=B">C</a> |

and so on


I would simply create a calculated column that displays the first letter of the Item Title and then use that in my views to display it for users. The group by view shows and totals how many "A>Z" items are in the list as well.

Set up column:

enter image description here

then you have a view that looks like this

enter image description here

and it can be grouped like this

enter image description here

  1. Add a calculated column that will hold only the first letter of the Title field. (fomula for this: =LEFT(Title,1) )
  2. Then I added the list grid web part.
  3. To add filter support I added above a rich text web part and added the HTML for A,B,C...Z and made each letter a hyperlink to the same page with adding "?FilterBook=A".
  4. Now, all i had to do is to add a query string filter web part (comes with SharePoint) and configure it to take the filter value from "FilterBook" query string and send it to filter the list grid web part below.


http://kwizcom.blogspot.com/2007/06/creating-a-z-filter-for-list.html http://sharepointkb.wordpress.com/2009/02/23/creating-a-z-expandingcollapsing-lists/ http://sympmarc.com/2009/06/19/alpha-selection-of-list-items/

  • 1
    Please add some important part of your answer here because once the link broken it will be of no use to the community members. You can include some essential part here and give the reference as your link – Aakash Maurya Jul 16 '16 at 3:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.