Extracting values from ArrayList

Discussion in 'ASP .Net' started by Sonny Sablan, Jan 28, 2005.

  1. Sonny Sablan

    Sonny Sablan Guest

    AryUnderNav = New ArrayList()
    AryUnderNav.Add("Under $50")
    AryUnderNav.Add("$50 - $100")
    AryUnderNav.Add("$100 - $200")
    AryUnderNav.Add("$200 +")

    UnderNav.DataSource = AryUnderNav
    UnderNav.DataBind()

    ....


    I want to list these items horizontally on the page. What is the syntax to get the value of each Array item?

    Here is what I've tried to do.

    <asp:DataList id="UnderNav" RepeatDirection="Horizontal" runat=server>
    <ItemTemplate>

    {{{{{{{{{{{ I want a URL here with the Index number in the href and the string value as the link text. }}}}}}}}}}

    </ItemTemplate>
    </asp:DataList>



    Thanks

    Sonny Sablan
     
    Sonny Sablan, Jan 28, 2005
    #1
    1. Advertisements

  2. Sonny Sablan

    Karl Seguin Guest

    Just do
    <%# Container.DataItem %>

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    AryUnderNav = New ArrayList()
    AryUnderNav.Add("Under $50")
    AryUnderNav.Add("$50 - $100")
    AryUnderNav.Add("$100 - $200")
    AryUnderNav.Add("$200 +")

    UnderNav.DataSource = AryUnderNav
    UnderNav.DataBind()

    ...


    I want to list these items horizontally on the page. What is the syntax to get the value of each Array item?

    Here is what I've tried to do.

    <asp:DataList id="UnderNav" RepeatDirection="Horizontal" runat=server>
    <ItemTemplate>

    {{{{{{{{{{{ I want a URL here with the Index number in the href and the string value as the link text. }}}}}}}}}}

    </ItemTemplate>
    </asp:DataList>



    Thanks

    Sonny Sablan
     
    Karl Seguin, Jan 29, 2005
    #2
    1. Advertisements

  3. Sonny Sablan

    Sonny Sablan Guest

    Thanks...

    Also,

    How do I extract the index of the data?
    And how can I use a datalist that does not write a table?

    I want to list the items without cells.

    Sonny
     
    Sonny Sablan, Jan 29, 2005
    #3
  4. Sonny Sablan

    Karl Seguin Guest

    Sonny:
    Try
    <%# Container.ItemIndex %> but remember that it's 0 based.

    If you want more control over how your databound controls are created, I
    suggest you look at the Repeater control which gives you great flexibility.

    Karl
     
    Karl Seguin, Jan 29, 2005
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.