Datalist array binding issues

Discussion in 'ASP .Net' started by =?Utf-8?B?c3R1ZGVuNzcx?=, Nov 3, 2006.

  1. Thanks in advance to anyone who can help :)

    I have my datalist bound to a normal, single dimension string array (with
    three elements) as its data source. In the scripting for the datagrid, I have
    it creating a table element in the <HeaderTemplate> and creating a row in the
    <ItemTemplate> section. The <FooterTemplate> only has a closing </table> tag
    within it.

    The problem:
    The datagrid is repeating all of the elements in the array as rows in run
    time. (i.e., the datalist is repeating the same elements in THREE rows). The
    # of times it repeats is dependent on the number of items in the array (i.e.
    two elements in the array, and the datalist will repeat the row two times)

    Here's the script:
    <asp:DataList ID="dlTest" runat="server"><HeaderTemplate><table><tr
    style='color:#FFFFFF; background-color:#0000cc'><th>Name</th><th>Phone
    Number</th><th>Title</th></tr></HeaderTemplate>
    <ItemTemplate><tr><td><%#this.stuff[0]
    %></td><td><%#this.stuff[1]
    %></td><td><%#this.stuff[2]%></td></tr></ItemTemplate>
    <FooterTemplate></table></FooterTemplate>
    </asp:DataList>

    Where [stuff] is the name of the string array.
    Anyone?
     
    =?Utf-8?B?c3R1ZGVuNzcx?=, Nov 3, 2006
    #1
    1. Advertising

  2. You ItemTemplate databinds to the same first 3 array items. According to
    this, if the array has 10 items, you will get 10 rows with the same 3 first
    items. Is it what you are getting? It is not clear what exactly you are
    trying to achieve. Do you want to have three items in each row?

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "studen771" <> wrote in message
    news:...
    > Thanks in advance to anyone who can help :)
    >
    > I have my datalist bound to a normal, single dimension string array (with
    > three elements) as its data source. In the scripting for the datagrid, I
    > have
    > it creating a table element in the <HeaderTemplate> and creating a row in
    > the
    > <ItemTemplate> section. The <FooterTemplate> only has a closing </table>
    > tag
    > within it.
    >
    > The problem:
    > The datagrid is repeating all of the elements in the array as rows in run
    > time. (i.e., the datalist is repeating the same elements in THREE rows).
    > The
    > # of times it repeats is dependent on the number of items in the array
    > (i.e.
    > two elements in the array, and the datalist will repeat the row two times)
    >
    > Here's the script:
    > <asp:DataList ID="dlTest" runat="server"><HeaderTemplate><table><tr
    > style='color:#FFFFFF; background-color:#0000cc'><th>Name</th><th>Phone
    > Number</th><th>Title</th></tr></HeaderTemplate>
    > <ItemTemplate><tr><td><%#this.stuff[0]
    > %></td><td><%#this.stuff[1]
    > %></td><td><%#this.stuff[2]%></td></tr></ItemTemplate>
    > <FooterTemplate></table></FooterTemplate>
    > </asp:DataList>
    >
    > Where [stuff] is the name of the string array.
    > Anyone?
     
    Eliyahu Goldin, Nov 5, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jordan
    Replies:
    2
    Views:
    2,547
    Jordan
    Feb 10, 2004
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,916
  3. Amit
    Replies:
    6
    Views:
    13,843
    Assimalyst
    Oct 24, 2006
  4. Replies:
    2
    Views:
    874
    Kevin Grover
    Oct 20, 2006
  5. JcFx
    Replies:
    0
    Views:
    291
Loading...

Share This Page