0

我想要我的中继器行 - 当单击扩展时,面板中的文本框很少它。当再次单击该行时,面板必须变为不可见。

在此先感谢您的帮助

<asp:Repeater ID="RepSample" runat="server" DataSourceID="SqlDataSource1">
    <HeaderTemplate>
        <table cellpadding="1" cellspacing="1" width="100%" style="font-family: Verdana;
            border: 1px solid #C0C0C0; background-color: #D8D8D8">
            <tr bgcolor="#FF781E">
                <th>
                    LicenseID
                </th>
                <th>
                    LicenseName
                </th>
                <th>
                    StartDate
                </th>
                <th>
                    EndDate
                </th>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
        <tr style="background-color: White">
            <td>
                <%#DataBinder.Eval(Container, "DataItem.LicenseID")%>
            </td>
            <td>
                <%#DataBinder.Eval(Container, "DataItem.LicenseName")%>
            </td>
            <td>
                <%#DataBinder.Eval(Container, "DataItem.StartDate")%>
            </td>
            <td>
                <%#DataBinder.Eval(Container, "DataItem.EndDate")%>
            </td>
        </tr>
    </ItemTemplate>
    <AlternatingItemTemplate>
        <tr>
            <td>
                <%#DataBinder.Eval(Container, "DataItem.LicenseID")%>
            </td>
            <td>
                <%#DataBinder.Eval(Container, "DataItem.LicenseName")%>
            </td>
            <td>
                <%#DataBinder.Eval(Container, "DataItem.StartDate")%>
            </td>
            <td>
                <%#DataBinder.Eval(Container, "DataItem.EndDate")%>
            </td>
        </tr>
    </AlternatingItemTemplate>
    <FooterTemplate>
        </table></FooterTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:KTestConnectionString %>"
    SelectCommand="SELECT LicenseID, LicenseName, StartDate, EndDate FROM Krish">
</asp:SqlDataSource>
4

1 回答 1

1

jQuery 可以帮助...

使用下面的 jQuery 代码制作你的jQuery 插件...

(function($) {
    $.fn.extend({
        collapsiblePanel: function() {
            //Call the ConfigureCollapsiblePanel function for the selected element
            return $(this).each(ConfigureCollapsiblePanel);
        }
    });
})(jQuery);

function ConfigureCollapsiblePanel() {
    //Wrap the contents of the container within a new div.
    $(this).children().wrapAll("<div class='collapsibleContainerContent'></div>");

    //Create a new div as the first item within the container.
    $("<div class='collapsibleContainerTitle'></div>").prependTo($(this));

    //Assign a call to CollapsibleContainerTitleOnClick for the click event of the new div.
    $(".collapsibleContainerTitle", this).click(CollapsibleContainerTitleOnClick);
}

function CollapsibleContainerTitleOnClick() {
    //The item clicked is the new div... get this parent (the overall container) and toggle the content within it.
    $(".collapsibleContainerContent", $(this).parent()).slideToggle();
}

aspx 标记部分

在你的里面放一个 divRepeater ItemTemplate并给它类collapsibleContainer

<asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
        <div class="collapsibleContainer">
            <%-- Put your text boxes and other contents here --%>
        </div>
    </ItemTemplate>
</asp:Repeater>

现在,只剩下页面中的$().ready函数了。

$().ready(function() {
    $(".collapsibleContainer").collapsiblePanel();
});

当然,您需要将 jQuery 插件引用作为脚本标签包含在您的页面上。

于 2013-09-12T05:18:45.970 回答