2012-10-15 110 views
1

我不知道這裏發生了什麼,這段代碼可以正常工作,並且沒有任何問題,然後它突然給出了沒有任何理由的提到的錯誤,然後錯誤消失了。 錯誤是在該行'>Column_Name既不是DataColumn也不是DataRelation的表格DefaultView

<asp:SqlDataSource ID="SqlDataSourceCountries" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices1 %>" 
       SelectCommand="SELECT  [CountryID], [country], 
         (SELECT  COUNT(JobID) AS [J] 
          FROM   [Job] 
          WHERE  ([Country].[CountryID] = [CountryID])) AS [JobCount] 
          FROM   [Country] AS [Country] ORDER BY [JobCount] DESC, [country] ASC"> 
      </asp:SqlDataSource> 

      <script type="text/javascript"> 
       $(document).ready(function() { 
        $("ul[id*=myid] li").click(function() { 

         document.getElementById("<%= DivCountries.ClientID %>").style.visibility = 'hidden'; 

         document.getElementById('pSelectedCountry').innerHTML = $(this).html(); 
         $("#<%=hSelectedCountryID.ClientID%>").val(this.id); 
         $("#<%=hSelectedCountryName.ClientID%>").val(this.innerHTML); 
         control1OnLoadHandler(); 

        }); 
       }); 
      </script> 
      <ul id='myid' class="bulletedList"> 
       <asp:Repeater ID="RepeaterCountryList" runat="server" DataSourceID="SqlDataSourceCountries"> 
        <ItemTemplate> 
         <li id='<%# Eval("[CountryID]") %>'><a> 
          <%# Eval("[country]") %></a> <a style="color: #808080; font-weight: normal;">(<%# Eval("[JobCount]") %>)</a> 
         </li> 
        </ItemTemplate> 
       </asp:Repeater> 
      </ul> 

回答

0

我認爲這個問題是與[]的。

嘗試這樣的事情

<ItemTemplate> 
<li id='<%# Eval("CountryID") %>'> 
<a><%# Eval("[country]") %></a> <a style="color: #808080; font-weight: normal;">(<%# Eval("JobCount") %>)</a> 
</li> 
</ItemTemplate> 

也許改變您的查詢,爲brackets aren't usually neccessary

此外,這是混亂的,你的表名是國家以及您選擇的項目: SELECT ...[country]...FROM [Country] AS [Country]...

0

必須添加特定表的主鍵字段選擇查詢

稍後可以通過使用列末尾的可見來隱藏它。

<telerik:GridBoundColumn DataField="Subject" visible="false">

相關問題