Urgent - How to use Alphabetical anchor tags to search in the database in an application with coding?

Posted on 2006-04-27
Last Modified: 2008-03-17
I have a search form which will have alphabetical listing in the main form.

When the user clicks on a specific alphabet it should search in the database for that particular alphabet and brings the results as a datagrid of the lastnames which will starts with that alphabet and should display as a separate page.

How can I accomplish this task?

Mine is a application and I am using for my coding.  Please help
Question by:amruthanet
    LVL 6

    Accepted Solution

    Your alphabetic link should open a new window passing the indicated letter in either the query string or hiding it in the form and use a parent / child relationship (probably not the right terminology) to access the variable. In this window will be a page that you create that queries the database and binds the results to the dataset.

    Your links should look something like this:
     <a href="myResultspage.aspx?LetterId=a" target=_blank>A</a>
     <a href="myResultspage.aspx?LetterId=b" target=_blank>B</a>
     <a href="myResultspage.aspx?LetterId=c" target=_blank>C</a>
     <a href="myResultspage.aspx?LetterId=d" target=_blank>D</a>

    MyResults should do something like this:

      Dim lastInitial as string
         lastInitial = Request.QueryString("LetterId")
         dim sSql as string = "SELECT LastName FROM myTable WHERE LastName LIKE '" & lastInitial & "%'"

         dim myConnection as new SqlConnection (connectionString)
         dim myCommand as new SqlCommand(sSql, myConnection)

         dim myReader as SqlDataReader = myCommand.ExecuteReader()

        myDataGrid.DataSource = myReader
        ' this try catch block will catch problems with the database connections
        ' you should put in logic to make sure the data in the query string is what you are expecting
      end try

    Author Comment

    Thanks.  It is working fine.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now