如何将这个jquery方法附加到网格视图中的所有控件

how to attach this jquery method to all control inside grid view

本文关键字:视图 网格 控件 jquery 方法      更新时间:2023-09-26

我有一个网格视图,它在更新面板中有下拉列表。我只想在这个网格视图中所有的下拉行为,比如图像+文本(用下拉列表绑定图像)。此处已成功绑定图像。但是在这里,所有可能已经生效的控件都没有正确地呈现。

这是我的jquery代码:

<script type="text/javascript" src="../js/jquery.dd.js"></script>
<script type="text/javascript" language="javascript">
    $(document).ready(function (e) {
        try {
            $("#<%=DDL_Column_List.ClientID %>").msDropDown();
            $("#<%=DDL_StatusList1.ClientID %>").msDropDown();//Grid view Drop Down List 1
            $("#<%=DDL_GroupList1.ClientID %>").msDropDown();//Grid view Drop Down List 2
            $("#<%=drp_title.ClientID %>").msDropDown();
            $("#<%=DDL_StatusList.ClientID %>").msDropDown();
            $("#<%=DDL_GroupList.ClientID %>").msDropDown();
            $("#<%=DDL_CountryNames.ClientID %>").msDropDown();
            $("#<%=DDL_StateNames.ClientID %>").msDropDown();
        } catch (e) {
            alert(e.message);
        }
    });
</script>

然而,这只会导致网格视图下拉列表的最后一行生效。

我只想用这个jquery函数来渲染所有控件。有没有办法在网格视图RowDataBind,RowCreated中附加这个jquery函数,以便正确渲染。

如果你想把这种效果添加到每个下拉列表(选择html中的元素),那么你可以做例如:

$(function() {
    $(".myGridviewClass select").msDropDown();
});