首页 新闻 会员 周边

数据绑定的问题

0
悬赏园豆:100 [已关闭问题]

List<string> myList = new List<string> { "text1", "text2", "text3", "text4", "text5", "text6", "text7", "text8" };

 

我想把myList绑定到Repeater上。但是Repeater的每个Item要绑定两项myList项。应该怎么做?如:Repeater的第一项显示为text1,text2

Einstein.P的主页 Einstein.P | 初学一级 | 园豆:100
提问于:2008-10-20 18:21
< >
分享
其他回答(3)
0

 <asp:DataList ID="rptItem" runat="server" RepeatColumns="3" Width="100%" />
使用DataList直接搞定,为什么要用Repeater

码尔代夫iimax | 园豆:3138 (老鸟四级) | 2008-10-20 20:01
0

这个好解决,用这种方式吧。

             ArrayList values = new ArrayList();

             values.Add(new ListItem("text1", "text2"));
             values.Add(new ListItem("text3", "text4"));
             values.Add(new ListItem("text5", "text6"));

             Repeater1.DataSource = values;
             Repeater1.DataBind();

Code
public class ListItem {

private string key;
private string value;

public ListItem (string key, string value) {
this.key = key;
this.value = value;
}

public string Key{
get {
return key;
}
}

public string Value{
get {
return value;
}
}
}
RicoRui | 园豆:3663 (老鸟四级) | 2008-10-20 20:29
0

噢,来晚了。二楼正解

KangKang | 园豆:10 (初学一级) | 2008-10-21 22:28
0

嗯,来晚了

Geeks | 园豆:560 (小虾三级) | 2008-11-03 17:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册