泛型实体类List<>绑定到repeater
2013-12-30 15:35
323 查看
后台代码:
说明:Model.news是实体类,GetList(out long)方法返回List<Model.news>.
前台代码:
说明:title为实体类Model.news的一个属性。
另绑定List<string>时直接用Container.DataItem 即可。
private void bindnewslist() { long num = 100L; List<Model.news> news = _news.GetList(out num); this.newslist.DataSource = news; this.newslist.DataBind(); }
说明:Model.news是实体类,GetList(out long)方法返回List<Model.news>.
前台代码:
<ul class="dot"> <asp:Repeater ID="newslist" runat="server" > <ItemTemplate> <li><a href="#"><%# (Container.DataItem as Model.news).title %></a></li> </ItemTemplate> </asp:Repeater> </ul>
说明:title为实体类Model.news的一个属性。
另绑定List<string>时直接用Container.DataItem 即可。
相关文章推荐
- repeater绑定泛型list<string>
- 【源码】List<T>泛型绑定repeater,以及repeater的交替绑定
- DataTable转换为List<Model>的通用类(绑定Repeater智能提示)
- [转]WinForm DataGridView 绑定泛型List(List<T>)/ArrayList不显示的原因和解决
- winform:对dataGridView绑定的泛型List<T> 的简单CRUD
- gridview 绑定list<实体类>
- Repeater 绑定List<string>
- DataTable转换为List<Model>的通用类(绑定Repeater智能提示)
- Repeater绑定数据源为List<t>提示t无x属性
- 泛型与反射机制处理ComBox绑定的数据源是List<实体对象>
- 委托,泛型List<>[Sort (),FindAll (),BinarySearch ()] ,泛型绑定下拉框
- WinForm DataGridView 绑定泛型List(List<T>)/ArrayList不显示的原因和解决
- WinForm DataGridView 绑定泛型List(List<T>)/ArrayList不显示的原因和解决
- List<string> 绑定Repeater
- Gridview 绑定泛型List<T> 排序方法
- DataGridview 绑定泛型List<T>
- C# List<T> 泛型
- list<E>泛型的问题
- 【C#基础知识】——List<T>And Dictionary<K,V>泛型集合
- Repeater绑定List泛型对象