zoukankan      html  css  js  c++  java
  • repeater操作

    protected void rpRole_ItemDataBound(object sender, RepeaterItemEventArgs e)

    {

        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)

        {

            DataRowView drv = e.Item.DataItem as DataRowView;

            string roleid = drv["Id"].ToString();

            CheckBox chb = e.Item.FindControl("chbId") as CheckBox;

     

            if (ht.ContainsValue(roleid))

            {

                chb.Checked = true;

            }

     

        }

    }

     

     

     

    --关于Repeater中嵌套Repeater写法,注意此时html生成二级Repeater的id是多个

    protected void rpFn1_ItemDataBound(object sender, RepeaterItemEventArgs e)

    {

        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)

        {

            DataRowView drv = e.Item.DataItem as DataRowView;

            int functionId = Convert.ToInt32( drv["Id"].ToString());

     

            Repeater rp2 = (Repeater)e.Item.FindControl("rpFn2"); --如果不这样做,就报"当前上下文中不存在名称rpFn2"

     

            DataSet ds2 = new DataSet();

            ds2 = bllF.GetList(-1, "ParentId=" + functionId, "SortBy desc");

            rp2.DataSource = ds2;

            rp2.DataBind();

     

        }

    }

     

     

     

    datarow[] 绑定可以到datalist等控件

     

     

     刚开始以为不可以绑定到datalist gatagrid repeater等控件 原来是不会写

    DataRow[] dr=dt.Select();

       DataGrid1.DataSource=dr;

       DataGrid1.DataBind();

    页面得写为

    <asp:Label text='<%# DataBinder.eval_r(Container.DataItem,"["huifuName"]")%>' Runat=server></asp:Label>

    不能写为<asp:Label text='<%# DataBinder.eval_r(Container.DataItem,"huifuName")%>' Runat=server></asp:Label>

    也不能写为<%# ((DataRowView)Container.DataItem["huifuName"]%>

    当然一般我们使用选择都是在dataview上操作的 然后将dataview绑定到。。

     

    rpFn1_ItemDataBound事件中不能写DataRowView drv = e.Item.DataItem as DataRowView;

    要写成:DataRow drv = e.Item.DataItem as DataRow;

     

  • 相关阅读:
    ELM学习
    《进化》从孤胆极客到高效团队
    《人件》《PeopleWare》 【美】Tom DeMarco TimothyLister 著 肖然 张逸 滕云 译
    《进化》从孤胆极客到高效团队---Notes1
    大数据第一部分LInux学习Note1
    C#Windows窗体初学
    C#初学笔记(Windows编程的基本概念)
    C#学习2017-9-26(读取文本文件和读取二进制文件)Notes9
    C#学习2017-9-26Notes8(文件和流,FileStream类)
    C#学习笔记Notes8(接口,接口实现,程序集,命名空间,using)
  • 原文地址:https://www.cnblogs.com/huaci/p/3375892.html
Copyright © 2011-2022 走看看