添加字符串项DataList控件asp.net [英] add string item to datalist asp.net
本文介绍了添加字符串项DataList控件asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我与DataList控件在asp.net C#的工作。我想补充的字符串作为DataList控件的项目。我这样做,请按照code:
I am working with DataList in asp.net C#. I want to add strings as an item to datalist. I do this by following code:
ArrayList al = new ArrayList();
for (int i = 0; i < 2; i++) {
al.Add(i.toString());
}
DataList2.DataSource = al;
DataList2.DataBind();
但是,当我运行程序,我不能看到数字0和1。相反,我看到下面的图片为DataList控件:
But when I run the program I cannot see the numbers 0 and 1. Instead I see following picture as datalist:
我的号码?是否有人知道解决的办法?注意,任务是要添加到数据列表字符串的数组。
Where is my numbers? Does someone know any solution? Note that the task is to add to the datalist the array of string.
在DataList code是:
The datalist code is:
<asp:DataList ID="DataList2" runat="server" BackColor="White"
BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4"
GridLines="Both">
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<ItemStyle BackColor="White" ForeColor="#330099" />
<SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
</asp:DataList>
此外,是否有可能滚动添加到DataList?
Moreover, is it possible to add scroll to the datalist?
推荐答案
添加到您的DataList的的ItemTemplate
如下:
Add to your DataList an ItemTemplate
as below:
<ItemTemplate>
<%# Container.DataItem %>
</ItemTemplate>
这篇关于添加字符串项DataList控件asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文