首页 > 其他 > 详细

RadioButtonList的使用

时间:2016-04-26 19:18:27      阅读:217      评论:0      收藏:0      [点我收藏+]
前台绑定:
<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;
                    }
                }

  

 

RadioButtonList的使用

原文:http://www.cnblogs.com/sll-fuling/p/5435984.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!