x
'),c.close();var d=c.documentElement.scrollHeight>c.body.scrollHeight;return a.parentNode.removeChild(a),b=d?document.documentElement:document.body}var b=null;Object.defineProperty(document,"scrollingElement",{get:a})}();var b;return{afterOpen:function(c){c||(b=document.scrollingElement.scrollTop,document.body.classList.add(a),document.body.style.top=-b+"px")},beforeClose:function(c){c||(document.body.classList.remove(a),document.scrollingElement.scrollTop=b)},getScrollTop:function(){return b}}}("popup-open"); 
  • 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    Repeater绑定dictionary数据源代码及报错解决
    .aspx页面代码
    复制代码 代码如下:

    asp:Repeater ID="Repeater1" runat="server">
    ItemTemplate>
    %# ((KeyValuePairint, ListUser>>)Container.DataItem).Key %> br />
    asp:Repeater ID="Repeater2" runat="server" DataSource='%# ((KeyValuePairint, ListUser>>)Container.DataItem).Value %>'>
    ItemTemplate>
    %# (Container.DataItem as User).Id %>
    %# (Container.DataItem as User).Name %>
    /ItemTemplate>
    /asp:Repeater>
    hr />
    /ItemTemplate>
    /asp:Repeater>

    .aspx.cs后置代码
    复制代码 代码如下:

    public partial class Temp : System.Web.UI.Page
    {
    Dictionaryint, ListUser>> dict = new Dictionaryint, ListUser>>();
    protected void Page_Load(object sender, EventArgs e)
    {
    dict.Add(1, new ListUser>
    {
    new User{Id = 1, Name = "aa"}
    ,new User{Id = 2, Name = "bb"}
    });
    dict.Add(2, new ListUser>
    {
    new User{Id = 3, Name = "cc"}
    ,new User{Id = 4, Name = "dd"}
    });
    Repeater1.DataSource = dict;
    Repeater1.DataBind();
    }
    }
    public class User
    {
    public int Id{get;set;}
    public string Name{get;set;}
    }

    如果报以下错误:
    repeater 使用的是无效数据源。有效数据源必须实现 IListSource 或 IEnumerable?
    是因为数据源类型问题,比如 DataTable DataSet Xml Arrry 集合
    像 String int 对象 这样的类型是不能直接作为它的数据源的,尤其要注意对象引起的问题
    您可能感兴趣的文章:
    • Repeater事件OnItemCommand取得行内控件的方法
    • Repeater控件与PagedDataSource结合实现分页功能
    • Repeater控件实现编辑、更新、删除等操作示例代码
    • Repeater怎么实现多行间隔显示分隔符
    • Repeater中嵌套Repeater的示例介绍
    • repeater做删除前弹窗询问实例
    • 给Repeater控件里添加序号的5种才常见方法介绍
    • asp.net Repeater 数据绑定的具体实现(图文详解)
    • .net JS模拟Repeater控件的实现代码
    • Repeater控件绑定的三种方式
    • 利用js的Node遍历找到repeater的一个字段实例介绍
    • ASP.NET笔记之 Repeater的使用
    • asp.net Repeater分页实例(PageDataSource的使用)
    • asp.net中使用repeater和PageDataSource搭配实现分页代码
    • Repeater里switch的使用方法
    • Repeater控件动态变更列(Header,Item和Foot)信息(重构cs)
    • Repeater的FooterTemplate显示某列总计思路与代码
    • 嵌套repeater示例分享
    上一篇:ASP.NET 页面事件执行顺序介绍
    下一篇:基于.NET程序默认启动线程数讲解
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯 版权所有

    《增值电信业务经营许可证》 苏ICP备15040257号-8

    Repeater绑定dictionary数据源代码及报错解决 Repeater,绑定,dictionary,数据,