473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 3689
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jurjen de Groot | last post by:
I have an ArrayList with NewsItem objects wich have properties 'newsDate' and 'newsText' I can off course bind the ArrayList to the Datalist, but how do I procede from there ? In the...
2
by: Mark | last post by:
I have a datalist (see code below). Assume that the datalist is populated with 10 records of data. How do I programatically grab all the data in ALL the columns of the selected record? I've been...
5
by: Ian O'Rourke | last post by:
I'm a bit confused by the datalist. I can put an item in the datalist in editmode by the following dtlBooks.EditItemIndex = e.Item.ItemInde BindBooks( This works great, the problem is when I...
8
by: Nevyn Twyll | last post by:
I have a multi-level datalist setup: DataList1 DataList2 MyGrid I have columns explicitly defined for the grid in the html. Sometimes, On the initial Load() of the Page, I want to add extra...
4
by: bienwell | last post by:
Hi all, Data displayed on the datalist control is bound by the column name of the dataset like this : <%# DataBinder.Eval(Container.DataItem, "title")%> Could I use an element of the array...
5
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able...
5
by: Laura K | last post by:
I am having difficulty binding data to my datalist. The data list does not show. I have gone round and round for two days. I could really use some help looking through this code and seeing where...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
4
by: Peter | last post by:
I have a DataList and each item in the datalist has an imge, I want to change the datalist item image on the client side when user clicks a button. How would I do that with JavaScript, does anyone...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.