Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Dynamically generate a-z grouped & hyperlinked index from a list

Dynamically generate a-z grouped & hyperlinked index from a list

Scheduled Pinned Locked Moved ASP.NET
databasehelptutorialhtmlalgorithms
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Josh Blair
    wrote on last edited by
    #1

    Hello, I have been looking examples of how to create an A-Z grouped index page from a list of data. This index page will contain a hyperlinked list of letters of the alphabet a,b,c...z that link to HTML "a name" tags within the same page. These links will that point to the correct letter of the alphabet which will correspond to the correct alphabetically grouped subset of data. This is a common feature on many sites and I'm sure this problem has been solved many times, it just that I think I am searching using the wrong keywords. This solution would likely include some combination of repeaters and/or datalists, and possibly a custom pager. My list currently contains about 1000 items that I pull from a SQL table. I'd like to only hit the database once to grab the list of data if possible. This is hard to articulate, let me try to explain this with an example: There is an A-Z index on the top of the page (and maybe on the bottom) like this: A, B, C.....Z (if a user clicks the C, they are redirected to the names in the list that start with a C A = abc abe about ... B = ball barge bat ... C <-- user is directed here when they click on the C in the A-Z index above) = car cat cave Thanks for the help,

    Josh Blair Golden, CO

    T 1 Reply Last reply
    0
    • J Josh Blair

      Hello, I have been looking examples of how to create an A-Z grouped index page from a list of data. This index page will contain a hyperlinked list of letters of the alphabet a,b,c...z that link to HTML "a name" tags within the same page. These links will that point to the correct letter of the alphabet which will correspond to the correct alphabetically grouped subset of data. This is a common feature on many sites and I'm sure this problem has been solved many times, it just that I think I am searching using the wrong keywords. This solution would likely include some combination of repeaters and/or datalists, and possibly a custom pager. My list currently contains about 1000 items that I pull from a SQL table. I'd like to only hit the database once to grab the list of data if possible. This is hard to articulate, let me try to explain this with an example: There is an A-Z index on the top of the page (and maybe on the bottom) like this: A, B, C.....Z (if a user clicks the C, they are redirected to the names in the list that start with a C A = abc abe about ... B = ball barge bat ... C <-- user is directed here when they click on the C in the A-Z index above) = car cat cave Thanks for the help,

      Josh Blair Golden, CO

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      You could do this in many ways. I suggest nested repeater controls. One repeater control get one record for each heading A, B, C. In each item template add another repearter with your details. That ought to be really easy, which part are you stuck on? Really it should be quite simple. You can use HTML Tables, Repearter, GridView etc... Here is a some sample code to create a dataset for you. I'm assuming you know how to get a dataTable from the database. You have to right write your own code for that. DataSet ds = new DataSet(); SqlParameter[] parameter = new SqlParameter[1]; parameter[0] = new SqlParameter("@EffectiveDate", EffectiveDate); DataTable dtParent = UAIG.Data.DataClass.GetDataTable("dbo.uspGetMenuHeader", parameter); parameter[0] = new SqlParameter("@EffectiveDate", EffectiveDate); DataTable dtChildren = UAIG.Data.DataClass.GetDataTable("dbo.uspGetMenuDetail", parameter); dtParent.TableName = "dtParent"; dtChildren.TableName = "dtChildren"; ds.Tables.Add(dtParent); ds.Tables.Add(dtChildren); ds.Relations.Add("children", ds.Tables["dtParent"].Columns["MenuID"], ds.Tables["dtChildren"].Columns["MenuID"]); foreach (DataRow rParent in ds.Tables["dtParent"].Rows) { //Add your code for parent tables row foreach (DataRow rChild in rParent.GetChildRows("children")) { //Add your code for child row } } -- modified at 15:08 Monday 2nd July, 2007

      I didn't get any requirements for the signature

      J 1 Reply Last reply
      0
      • T ToddHileHoffer

        You could do this in many ways. I suggest nested repeater controls. One repeater control get one record for each heading A, B, C. In each item template add another repearter with your details. That ought to be really easy, which part are you stuck on? Really it should be quite simple. You can use HTML Tables, Repearter, GridView etc... Here is a some sample code to create a dataset for you. I'm assuming you know how to get a dataTable from the database. You have to right write your own code for that. DataSet ds = new DataSet(); SqlParameter[] parameter = new SqlParameter[1]; parameter[0] = new SqlParameter("@EffectiveDate", EffectiveDate); DataTable dtParent = UAIG.Data.DataClass.GetDataTable("dbo.uspGetMenuHeader", parameter); parameter[0] = new SqlParameter("@EffectiveDate", EffectiveDate); DataTable dtChildren = UAIG.Data.DataClass.GetDataTable("dbo.uspGetMenuDetail", parameter); dtParent.TableName = "dtParent"; dtChildren.TableName = "dtChildren"; ds.Tables.Add(dtParent); ds.Tables.Add(dtChildren); ds.Relations.Add("children", ds.Tables["dtParent"].Columns["MenuID"], ds.Tables["dtChildren"].Columns["MenuID"]); foreach (DataRow rParent in ds.Tables["dtParent"].Rows) { //Add your code for parent tables row foreach (DataRow rChild in rParent.GetChildRows("children")) { //Add your code for child row } } -- modified at 15:08 Monday 2nd July, 2007

        I didn't get any requirements for the signature

        J Offline
        J Offline
        Josh Blair
        wrote on last edited by
        #3

        Thanks for the reply. I know I could iterate through my parent and child datatables but that seems like "brute force". I was hoping that there was a more elegant approach using built-in databinding. Or maybe way to configure 2 repeaters or datalists with a custom pager to accomplish this. I will try the brute force method and see where I get. If anyone else has a another alternative, please let me know. Cheers,

        Josh Blair

        T 1 Reply Last reply
        0
        • J Josh Blair

          Thanks for the reply. I know I could iterate through my parent and child datatables but that seems like "brute force". I was hoping that there was a more elegant approach using built-in databinding. Or maybe way to configure 2 repeaters or datalists with a custom pager to accomplish this. I will try the brute force method and see where I get. If anyone else has a another alternative, please let me know. Cheers,

          Josh Blair

          T Offline
          T Offline
          ToddHileHoffer
          wrote on last edited by
          #4

          If you want to use databinding, you can use the dataview object on each table. BTW, iterating through a table is not "Brute Force". The controls inside the repeater should all be created dynamically. There isn't really much difference from iterating through a table or calling an objects databind method. Pretty much the same thing happens.

          I didn't get any requirements for the signature

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups