0

jqueryでデータリストをバインドしたい。ここに私のクライアント側のコードがあります:

<head>
     <script src="jss/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {

            $.ajax({
                type: "POST",
                url: "WebForm1.aspx/GetProducts",
                data: '{}',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                failure: function (response) {
                    alert(response.d);
                },
                error: function (response) {
                    alert(response.d);
                }
            });
        });

        function OnSuccess(response) {
            $("[id*=dlOnFrontPageProducts]").attr("border", "1");
            var xmlDoc = $.parseXML(response.d);
            var xml = $(xmlDoc);
            var customers = xml.find("Table1");
            var row = $("[id*=dlOnFrontPageProducts] tr:last-child").clone(true);
            $("[id*=dlOnFrontPageProducts] tr:last-child").remove();
            $.each(customers, function () {
                alert(this);
                var customer = $(this);
                $(".Name", row).html(customer.find("Name").text());
                $(".BrandName", row).html(customer.find("BrandName").text());
                $(".MarketPrice", row).html(customer.find("MarketPrice").text());
                $(".CurrencyShortName", row).html(customer.find("CurrencyShortName").text());
                $(".Price", row).html(customer.find("Price").text());
                $(".WindowImageUrl", row).html(customer.find("WindowImageUrl").text());
                $(".SaleCount", row).html(customer.find("SaleCount").text());
                $(".IsActive", row).html(customer.find("IsActive").text());
                $("[id*=dlOnFrontPageProducts]").append(row);
                row = $("[id*=dlOnFrontPageProducts] tr:last-child").clone(true);
            });
        }

    </script>

</head>
<body>
    <asp:DataList runat="server" ID="dlOnFrontPageProducts" RepeatColumns="4" RepeatDirection="Horizontal"
        RepeatLayout="Table" EnableTheming="True" OnItemDataBound="dlChanceProducts_ItemDataBound">
        <ItemTemplate>
            <div class="box-product fixed">
                <div class="prod_hold">
                    <a class="wrap_link" href="ProductDetail.aspx?prid=<%# Eval("ProductId") %>"><span
                        class="images">
                        <asp:Image runat="server" ID="imgWindow" /></span> </a>
                    <div class="pricetag_small">
                        <span class="old_price">
                            <%# Eval("MarketPrice")%><%# Eval("CurrencyShortName")%></span> <span class="new_price">
                                <%# Eval("Price", "{0:n}")%>
                                <%# Eval("CurrencyShortName")%></span>
                    </div>
                    <div class="info">
                        <h3>
                            <%# Eval("Name") %></h3>
                        <p>
                            <%# Eval("BrandName")%></p>
                        <a class="add_to_cart_small" href="/core/ajaxresult.aspx?act=prod&prid=<%#Eval("ProductId")%>">
                            Sepete Ekle</a> <a class="wishlist_small" href="#">Listeme Ekle</a> <a class="compare_small"
                                href="#">Karşılaştır</a>
                    </div>
                </div>
            </div>
            <div class="clear">
            </div>
        </ItemTemplate>
    </asp:DataList>
</body>

返されたデータは正しいのですが、datalist がバインドされません。何か提案はありますか?

4

1 に答える 1