[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 451
  • Last Modified:

Does There Exist An Alphabetical Hyperlink Web Control

that will link each letter of the alphabet to the place in the GridView (or other control) where that letter begins in the list?

Also, if I want to display only those records that begin with the corresponding letter selected from the Hyperlink Link what would be the recommended approach?  

TIA
-Mari
0
Mariyam
Asked:
Mariyam
  • 3
  • 3
1 Solution
 
arif_eqbalCommented:
I don't think there's any such built in Control
You need to Filter the Records in Grid manually basde on Alphabet
0
 
MariyamAuthor Commented:
Okay, I can do that.  Can you tell me if and how I can use a wildcard with the filtering expression such as
             
                 Session["Letter"] = "A%"

to do the filtering so that I pick up any value in the FName field that begins with A?  I know how to do it in SQL but not in ASP.net.

Thanks for your help.
0
 
arif_eqbalCommented:
I hope what you are asking is you want to match if the string value stored in Session["Letter"] starts with "A"
If you need a complex matching you need to use RegEx though in this case the following would do

Dim Letter As String = Session["Letter"]
if Letter.StartsWith("A") then
    .....
End if
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
MariyamAuthor Commented:
I'm sorry, I forgot to mention I'm writing in C#.

I have a SQLDataSource which populates a GridView.  I have the the mode set to dataset and caching is enabled.  What I'm trying to do is click on a hyperlink where code executes which sets the Session value of the variable Letter to the corresponding letter which was clicked.  How do I then set the FilteringExpression of the SqlDataSource to compare the value of FName (field value returned by the SQLDataSource and displayed in the GridView) to use the Session value of the variable Letter.  I understand that I should compare FName.StartsWith(Letter) however I don't know how to properly access this value nor where to put this in the code-behind.

Or is it even possible to do it this way?  Should I just go ahead and use a data adapter, tables, rows & dataview?

Thanks for your help.  If you need me to increase the points, please just let me know.  Thanks.
0
 
arif_eqbalCommented:
Hi FoxProMari
looks like you are using VS 2005, Sorry but I have no idea of 2005 as of yet.
In the older version all you needed to do was set the RowFilter property of the DataGrid's Tabel's DefaultView to the Where clause for selecting Names starting with "A"
string Letter =  Session["Letter"];
MyDataTable.DefaultView.RowFilter="FName like '" + Letter + "%'"
then bind the Datagrid to the DataTable

I just tried the Net for 2005, it seems we need to user parameters for this, now in yor case what you can do is on the Hyperlink click pass a QueryString value as well to the Page and then Filter by QueryString look at this page

http://www.asp.net/QuickStart/aspnet/doc/data/databases.aspx

and for the specific Filter by QueryString
http://www.asp.net/QuickStart/util/srcview.aspx?path=~/aspnet/samples/data/GridViewQueryString.src&file=GridViewQueryString_cs.aspx&lang=C%23+Source
0
 
MariyamAuthor Commented:
Thanks.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now