zoukankan      html  css  js  c++  java
  • Repeater的Item项绑定DropDownList

    前台页面:

     <asp:Repeater ID="rptJgtList" runat="server" OnItemDataBound="rptJgtList_ItemDataBound">                            
        <ItemTemplate>
           <tr class="danhao" zz-jincheng='<%#Eval("kxsjd_jincheng")%>'>
              <td width="15%">
                <asp:DropDownList ID="ddl_FBType" runat="server">
                </asp:DropDownList>
              </td>                                    
           </tr>
         </ItemTemplate>
     </asp:Repeater>

    后台CS:

    /// <summary>
        /// 绑定发包类型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rptJgtList_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            DropDownList ddl;
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                ddl= (DropDownList)e.Item.FindControl("ddl_FBType");
    
                DataTable dt = newCB.GetTableds("zab_userList", "u_xingming,u_kahao,u_id", " u_zhuangtaiyg<>'离职' and u_states<>4 and u_zuming='设计组'", "u_xingming", 0);
                ddl.DataSource = dt;
                ddl.DataTextField = "u_xingming";
                ddl.DataValueField = "u_kahao";
                ddl.DataBind();
            //为DropDownList添加一行
                ddl.Items.Insert(0, "集团设计院");
                ddl.Items.Insert(1, "外援");
    
                if (!string.IsNullOrEmpty(DataBinder.Eval(e.Item.DataItem, "kxsjd_type").ToString().Trim()))
                {
                    try
                    {
                        ddl.Items.FindByValue(DataBinder.Eval(e.Item.DataItem, "kxsjd_type").ToString()).Selected = true;
                    }
                    catch (Exception)
                    {
    
                        ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('绘图员信息丢失,或者离职,无法加载,有问题请打集团网络部电话!');</script>");
                    }
                }
            }
        }
  • 相关阅读:
    nopCommerce中缓存学习
    EF
    路由
    webapi的加密方式
    生成N位数字随机数
    C# DataTable 转 实体类
    WebBrowser 打印
    文件上传控件,格式统一
    sqlserver 表循环-游标、表变量、临时表
    VB 老旧版本维护系列---迷之集合- dataTable
  • 原文地址:https://www.cnblogs.com/tianrui/p/3747071.html
Copyright © 2011-2022 走看看