repeater
循环一个选项卡div
每个div内都有个CheckBoxList <asp:Repeater ID="rptrLanguageDivs" runat="server" OnItemDataBound="rptrLanguageDivs_ItemDataBound">
        <ItemTemplate>
            <div id="idTab_Info<%# Container.ItemIndex+2 %>" class="tab">
                <i>
                    <%=GetLocaleResourceString("Admin.Localizable.EmptyFieldNote")%></i>
                <asp:Label ID="lblLanguageId" runat="server" Text='<%#Eval("LanguageId") %>' Visible="false"></asp:Label>
                <table class="adminContent">
                    <tr>
                        <td class="adminTitle">
                            <nopCommerce:ToolTipLabel runat="server" ID="lblLocalizedAttributeName" Text="<% $NopResources:Admin.ProductVariantAttributeValues.New.Name %>"
                                ToolTip="<% $NopResources:Admin.ProductVariantAttributeValues.New.Name.Tooltip %>"
                                ToolTipImage="~/Administration/Common/ico-help.gif" />
                        </td>
                        <td class="adminData">
                           <%-- <asp:TextBox runat="server" CssClass="adminInput" ID="txtNewLocalizedName" />--%>
                            <asp:CheckBoxList ID="cbl_ProductAttributeValueList" runat="server" RepeatDirection="horizontal" >
                            </asp:CheckBoxList>
                        </td>
                    </tr>
                </table>
            </div>
        </ItemTemplate>
    </asp:Repeater>绑定 protected void rptrLanguageDivs_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            ProductVariantAttribute pva = ProductAttributeService.GetProductVariantAttributeById(this.ProductVariantAttributeId);
            int ProductAttributeId = 0;
            if (pva != null)
            {
               ProductAttributeId=pva.ProductAttributeId;
            }
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                Language lg = (Language)e.Item.DataItem;
                int LanguageID = lg.LanguageId;
                CheckBoxList ckb = (CheckBoxList)e.Item.FindControl("cbl_ProductAttributeValueList");
                ckb.DataSource = ProductAttributeService.GetProductAttributeValues(LanguageID, ProductAttributeId, null);
                ckb.DataTextField = "Name";
                ckb.DataValueField = "ProductAttributeValueID";
                ckb.DataBind();
            }
        }
在外部有个按钮
点击如何判断 必须有一个CheckBoxList内被打勾,并且只能存在一个CheckBoxList被打勾
并取值

解决方案 »

  1.   

    很简单,你判读下,到底是那个Tab是正在使用状态,不就完事了。判读Tab的使用状态,不难吧!记得全部给分我。
      

  2.   

    我要是其中一个tab 打勾后切换到另外一耳光tab 打勾 
    然后再提交呢?
    分不是问题 问题是怎么解决这个问题
      

  3.   

    目前有个想法
    就是选项卡的
     <div id="idTab_Info<%# Container.ItemIndex+2 %>" class="tab">
    ID都是固定的  循环判断固定id下的checklistbox
      

  4.   

    遍历每一行,然后findcontrol~~~
      

  5.   

    foreach (RepeaterItem item in rep_user.Items)
                {
                    CheckBox cb = (CheckBox)item.FindControl("cb_id");
                    if (cb.Checked)
                }
      

  6.   

        protected void Button1_Click(object sender, EventArgs e)
        {
            bool  = false;
            for (int i = 0; i < rptrLanguageDivs.Items.Count; i++)
            {
                CheckBoxList ckb = (CheckBoxList)rptrLanguageDivs.Items[i].FindControl("cbl_ProductAttributeValueList");
                if (-1 != ckb.SelectedIndex)
                {
                     = true;
                }
            }
            if ()
            {
                Response.Write("有选中");
            }
            else
            {
                Response.Write("无选中");
            }
        }
      

  7.   

    我也觉得js方便点  是还没想到如何做你前台生成的html是什么样的?拿出来看看
      

  8.   

    <div id="idTab_Info2" class="tab" style="display: block;">
                    <i>
                        请注意,如果一个字段为空,标准字段将被使用.</i>
                    
                    <table class="adminContent">
                        <tbody><tr>
                            <td class="adminTitle">
                                
    <span class="nop-tooltip">
        <img id="ctl00_cph1_ctrlProductVariantAttributeValues_rptrLanguageDivs_ctl00_lblLocalizedAttributeName_imgToolTip" title="属性值的名称,例如'蓝'的颜色属性" src="Common/ico-help.gif" alt="?" style="border-width:0px;">
        <span id="ctl00_cph1_ctrlProductVariantAttributeValues_rptrLanguageDivs_ctl00_lblLocalizedAttributeName_lblValue" title="属性值的名称,例如'蓝'的颜色属性">名称</span>
    </span>
                            </td>
                            <td class="adminData">
                               
                                <table id="ctl00_cph1_ctrlProductVariantAttributeValues_rptrLanguageDivs_ctl00_cbl_ProductAttributeValueList" border="0">
    <tbody><tr>
    <td><input id="ctl00_cph1_ctrlProductVariantAttributeValues_rptrLanguageDivs_ctl00_cbl_ProductAttributeValueList_0" type="checkbox" name="ctl00$cph1$ctrlProductVariantAttributeValues$rptrLanguageDivs$ctl00$cbl_ProductAttributeValueList$0"><label for="ctl00_cph1_ctrlProductVariantAttributeValues_rptrLanguageDivs_ctl00_cbl_ProductAttributeValueList_0">赤</label></td>
    </tr>
    </tbody></table>
                            </td>
                        </tr>
                    </tbody></table>
                </div>
      

  9.   

    我也觉得js方便点  是还没想到如何做你前台生成的html是什么样的?拿出来看看
    已上图
      

  10.   


    Js代码:
            function CheckList(obj) {
                obj.checked === true && $(".chkselect").not($(obj)).each(function () { $(this).get(0).checked = false; })
            }
    Html代码:
    <div id="idTab_Info2" class="tab" style="display: block;">
                <i>请注意,如果一个字段为空,标准字段将被使用.</i>
                <table class="adminContent">
                    <tbody>
                        <tr>
                            <td class="adminTitle">
                                <span class="nop-tooltip">
                                    <img id="ctl00_cph1_ctrlProductVariantAttributeValues_rptrLanguageDivs_ctl00_lblLocalizedAttributeName_imgToolTip"
                                        title="属性值的名称,例如'蓝'的颜色属性" src="Common/ico-help.gif" alt="?" style="border-width: 0px;">
                                    <span id="ctl00_cph1_ctrlProductVariantAttributeValues_rptrLanguageDivs_ctl00_lblLocalizedAttributeName_lblValue"
                                        title="属性值的名称,例如'蓝'的颜色属性">名称</span> </span>
                            </td>
                            <td class="adminData">
                                <table id="ctl00_cph1_ctrlProductVariantAttributeValues_rptrLanguageDivs_ctl00_cbl_ProductAttributeValueList"
                                    border="0">
                                    <tbody>
                                        <tr>
                                            <td>
                                                <input id="ctl00_cph1_ctrlProductVariantAttributeValues_rptrLanguageDivs_ctl00_cbl_ProductAttributeValueList_0"
                                                    type="checkbox" name="ctl00$cph1$ctrlProductVariantAttributeValues$rptrLanguageDivs$ctl00$cbl_ProductAttributeValueList$0"
                                                    class="chkselect" onclick="CheckList(this)"><label for="ctl00_cph1_ctrlProductVariantAttributeValues_rptrLanguageDivs_ctl00_cbl_ProductAttributeValueList_0">赤</label>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
    加了一个class= "chkselect" 加了一个onclick = "CheckList(this)"
      

  11.   

    不能加在生成的HTML里面啊,我要加在生成前的
      

  12.   

    不能加在生成的HTML里面啊,我要加在生成前的
    他说的是浏览器自动生成的这两句代码吧~~~
      

  13.   

    不能加在生成的HTML里面啊,我要加在生成前的你生成前加这两个不就OK了????
      

  14.   

    正确答案已经出来了在 另外一个帖子
    http://bbs.csdn.net/topics/390508898