468,249 Members | 1,497 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Datalist array binding issues

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 <HeaderTemplateand creating a row in the
<ItemTemplatesection. The <FooterTemplateonly has a closing </tabletag
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?
Nov 3 '06 #1
1 3512
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" <st*******@discussions.microsoft.comwrote in message
news:2B**********************************@microsof t.com...
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 <HeaderTemplateand creating a row in
the
<ItemTemplatesection. The <FooterTemplateonly 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?

Nov 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jurjen de Groot | last post: by
2 posts views Thread by Mark | last post: by
5 posts views Thread by Ian O'Rourke | last post: by
5 posts views Thread by Laura K | last post: by
3 posts views Thread by Mirek Endys | last post: by
4 posts views Thread by Peter | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.