asp.net 获取 repeater checkbox 值

webform中获取repeat控件列表下的checkbox选中的值:

码农上代码:

复制代码
public static string getSelectedIDs(Repeater Rpt_)
        {
            string res = string.Empty;
            foreach (RepeaterItem rtpItem in Rpt_.Items)
            {
                HtmlInputCheckBox obj = rtpItem.FindControl("checkbox") as HtmlInputCheckBox;
                if (obj != null)
                {
                    if (obj.Checked == true)
                    {
                        res += obj.Value.ToString() + ",";
                    }
                }
            }
            if (!string.IsNullOrEmpty(res))
            {
                res = res.Remove(res.LastIndexOf(','));
            }
            return res;
        }
复制代码

 

码农都是有尊严的 转载请注明来源,谢谢  http://www.cnblogs.com/benpao/

webform中获取repeat控件列表下的checkbox选中的值:

码农上代码:

复制代码
public static string getSelectedIDs(Repeater Rpt_)
        {
            string res = string.Empty;
            foreach (RepeaterItem rtpItem in Rpt_.Items)
            {
                HtmlInputCheckBox obj = rtpItem.FindControl("checkbox") as HtmlInputCheckBox;
                if (obj != null)
                {
                    if (obj.Checked == true)
                    {
                        res += obj.Value.ToString() + ",";
                    }
                }
            }
            if (!string.IsNullOrEmpty(res))
            {
                res = res.Remove(res.LastIndexOf(','));
            }
            return res;
        }
复制代码

 

猜你喜欢

转载自www.cnblogs.com/Z7TS/p/10481307.html