多个复选框的读取选中

来源:互联网 发布:数控车床编程好学么 编辑:程序博客网 时间:2024/04/27 16:35
protected void ResponseCheckBoxHTML()
    {
        CreateCheckBoxHTML = string.Empty;
        List<VCollaborationService> lst = ServiceItemDataAccess.GetCategoryName();
        for (int i = 0; i < lst.Count; i++)
        {
            if (SelectCateogyrs != null && SelectCateogyrs.Count > 0)
            {
                CreateCheckBoxHTML += ("<input class='chkCategory' type='checkbox' name='chkCategory' id='bhkCategory" + lst[i].ProCategoryID + "' value='" + lst[i].ProCategoryID + "' " + (SelectCateogyrs.Contains(lst[i].ProCategoryID.ToString()) ? " checked='checked' " : "") + "/><label for='bhkCategory" + lst[i].ProCategoryID + "'>" + lst[i].CategoryName + "</label>");
            }
            else if (CsSelectCategorys != null && CsSelectCategorys.Count > 0)
            {
                CreateCheckBoxHTML += ("<input class='chkCategory' type='checkbox' name='chkCategory' id='bhkCategory" + lst[i].ProCategoryID + "' value='" + lst[i].ProCategoryID + "' " + (CsSelectCategorys.Contains(lst[i].ProCategoryID.ToString()) ? " checked='checked' " : "") + "/><label for='bhkCategory" + lst[i].ProCategoryID + "'>" + lst[i].CategoryName + "</label>");
            }
            else
            {
                CreateCheckBoxHTML += ("<input class='chkCategory' type='checkbox' name='chkCategory' id='bhkCategory" + lst[i].ProCategoryID + "' value='" + lst[i].ProCategoryID + "'/><label for='bhkCategory" + lst[i].ProCategoryID + "'>" + lst[i].CategoryName + "</label>");
            }
        }
    }
0 0
原创粉丝点击