选中特定行复选框时,在Gridview中显示DropDown

时间:2014-03-11 11:45:17

标签: c# jquery asp.net gridview

我希望在选中相同行的复选框时显示特定的行下拉列表。但是有问题,因为网格的所有下拉列表都显示在一行的复选框选择上。 这是网格:

  <asp:TemplateField HeaderText="Advertise Id" HeaderStyle-Width="150px" HeaderStyle-Font-Size="14px" HeaderStyle-ForeColor="Black">
                        <ItemTemplate>
                            <div style="text-align: left;">
                             <asp:TextBox runat="server" Width="120px" ReadOnly="true" ID="TextBoxAdvertiseId" Text='<%# Eval("AdvertiseIdName")%>' />
                                <input type="checkbox" class="CheckBoxImage" onclick="CheckBoxImage()" />

                            <asp:DropDownList CssClass="DDAdvertise" runat="server" Width="130px" ID="drpdwnadvertiseAdd"></asp:DropDownList>

                                 </ItemTemplate>
   </asp:TemplateField>

这是jquery代码:

  function CheckBoxImage() {
        var flag = false;
        $('.GridLocation input[type="checkbox"]').each(function () {

            var checkbox = $('.GridLocation input[type="checkbox"]');


            var row = $(this).parent().parent().parent().parent().parent();

            if ($(this).is(':checked')) {
                flag = true;
                $(row).find('.DDAdvertise').show(); // Problem is in .DDAdvertise as it is a classname so it's selecting all the dropdowns

            } else {
                $(row).find('.DDAdvertise').hide();
            }
            if (flag) {
                $(row).find('.DDAdvertise').show();
            }
            else {
                $(row).find('.DDAdvertise').hide();
            }
        });
    }

现在,问题是我在jquery中使用类名(.DDAdvertise),它显示了所有下拉列表。我希望显示特定的下拉列表,其中选中了行的复选框。

0 个答案:

没有答案