zoukankan      html  css  js  c++  java
  • Repeater中绑定DropDownList

    效果如图:

    后台代码如下 :

    /// <summary>
    /// 动态绑定Repeater中的指派下拉框
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void rptContent_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    DropDownList dllOperator = (DropDownList)e.Item.FindControl("dllOperator");
    dllOperator.DataSource = AdminUserService.GetList("");
    dllOperator.DataTextField = "realName";
    dllOperator.DataValueField = "id";
    dllOperator.DataBind();
    dllOperator.Items.Insert(0,new ListItem("请选择", "-99"));
    //找到分类Repeater关联的数据项
    DataRowView rowv = (DataRowView)e.Item.DataItem;//获取当前项行数据再去访问那一列.注意坐标索引是从0开始

    dllOperator.SelectedValue = rowv[4].ToString();
    }
    }

    前台代码:

        <asp:Repeater ID="repInfo" runat="server"   OnItemDataBound="rptContent_ItemDataBound">

      <asp:DropDownList ID="dllOperator" runat="server"></asp:DropDownList>

  • 相关阅读:
    学习进度条40
    学习进度条39
    学习进度条38
    学习进度条37
    学习进度条36
    iReport5.6.0使用说明
    Mysql 如何创建一张临时表
    SQL语句出现sql关键字
    SQL-order by两个字段同时排序
    js中==和===区别
  • 原文地址:https://www.cnblogs.com/lk516924/p/4819869.html
Copyright © 2011-2022 走看看