zoukankan      html  css  js  c++  java
  • RadioButtonList的使用

    前台绑定:
    <asp:RadioButtonList ID="hlBatchYuJi" runat="server" RepeatColumns="1" CellPadding="1" CellSpacing="1"> </asp:RadioButtonList>

      

    js判断选中

     var vRbtid = document.getElementById("hlBatchYuJi");
                var vRbtidList = vRbtid.getElementsByTagName("INPUT"); //得到所有radio
                for (var i = 0; i < vRbtidList.length; i++) {
                    if (vRbtidList[i].checked) {
                        BatchText = vRbtid.cells[i].innerText;   //获取绑定的text值
                        Batchvalue = vRbtidList[i].value;        //获取绑定的value值
                    } 
                }
                if (BatchText == "") {
                    alert("请选择育雏批次!");
                    return;
                }
    

      

    cs文件后台绑定

     LstBatch = BatchDB.Data.Where(o => o.EnID == UserInfo.EnId && LstChuJIIDs.Contains(o.FarmID) && !LstYiSheBatchID.Contains(o.ID)).ToList();
                hlBatchYuJi.DataSource = LstBatch;
                hlBatchYuJi.DataTextField = "BatchNo";
                hlBatchYuJi.DataValueField = "ID";
                hlBatchYuJi.DataBind();
    

    赋值初值,选中的 

    var Info = YISheDB.Data.ToInfo(reqID);//根据ID获取数据
                    hlBatchYuJi.Items.Insert(0, new ListItem(Info.BatchNo, Info.BatchID.ToString()));    //插入新的值
                    hlBatchYuJi.SelectedIndex = 0;
    
                    foreach (ListItem item in hlFarmJi.Items)                                            //循环判断选中
                    {
                        if (item.Value.ConvertType(0) == Info.FarmID)
                        {
                            item.Selected = true; 
                            break;
                        }
                    }
    

      

     

  • 相关阅读:
    经典机器学习算法总结
    从0开始学Python---01
    Android-Canvas.save() Canvas.restore() 总结
    Android-属性动画原理总结
    设计模式-外观模式
    设计模式-模板方法
    设计模式-装饰者模式
    设计模式-策略模式
    设计模式-工厂方法模式
    设计模式-简单工厂模式
  • 原文地址:https://www.cnblogs.com/sll-fuling/p/5435984.html
Copyright © 2011-2022 走看看