【问题标题】:Retrieving values only once without using ItemDataBoundEvent which repeatedly return the value仅检索一次值而不使用重复返回值的 ItemDataBoundEvent
【发布时间】:2011-06-13 14:31:06
【问题描述】:

在 DataService.cs 上,该函数返回如下列表:

[WebMethod()]
public SomeList[] GetListing(

在客户端,我有这个:

        function onListLoadSuccess(someLists) {            

            var dataList = $find('<%= DataList1.ClientID %>');
            dataList.set_dataSource(someLists);
            dataList.dataBind();

那么当它绑定到DataList1时:

        function onListItemDataBound(sender, e) {

            var item = e.get_item();
            if (item.get_isDataItemType()) {

                var someList = item.get_dataItem();
                alert(someList.Country);
                alert(someList.City);

我的问题是我只需要检索一次 Country 和 City,我想知道如何在不使用 onListItemDataBound 函数的情况下检索这些值,该函数重复返回值直到所有行都运行完。

【问题讨论】:

    标签: ajax datalist itemdatabound


    【解决方案1】:

    现在开始工作了.. 傻我!

            function onListLoadSuccess(someLists) {  
                alert(someLists[0].City);
                alert(someLists[0].Country);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-23
      • 1970-01-01
      • 2021-06-13
      • 2015-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-25
      相关资源
      最近更新 更多