This is a really old post but I found this article really helpful:
http://www.codeproject.com/Articles/3628/Letter-Alphanumeric-Based-Paging-in-ASP-NET
I used the UsersViewer.aspx and its attached UsersFilterControl.ascx
I created a public property in the Filter to pass the Users data source to the filter
public object UserDataSource
{
get
{
return mDataSource;
}
set
{
mDataSource = value;
}
}
And passed it to the filter control (about line 720 of UsersViewer.aspx - note do this after the initial WhereCondition has been applied to the UsersDataSource):
filterUsers.UserDataSource = srcUsers.DataSource;
In the letters_Bind() method from the above article I changed the binding so that it only shows the letters from users that we have in our datasource.
InfoDataSet<UserInfo> uds = (InfoDataSet<UserInfo>)this.UserDataSource;
Hashtable htUsers = new Hashtable();
foreach (UserInfo dr in uds)
{
string firstLetter = dr.LastName.Substring(0, 1).ToUpper();
if (!htUsers.ContainsKey(firstLetter))
{
htUsers.Add(firstLetter, firstLetter);
}
}
In the filter I changed the letters_ItemCommand (from the above article) to the below:
if (_letterFilter == "All")
{
WhereCondition = "";
}
else
{
WhereCondition = "Upper(LastName) like '" + _letterFilter + "%'";
}
// Raise OnFilterChange event
RaiseOnFilterChanged();