簡體   English   中英

ASP.NET轉發器不包含轉發器的定義

[英]ASP.NET repeater does not contain a definition for repeater

我正在嘗試使用轉發器創建一個asp.net表。 這是我創建表的代碼:

    <table class="pageViewTable" align="centre" border="1">
        <tr bgcolor="green">
            <th>DateTime</th>
            <th>Page</th>
            <th>Location</th>
            <th>IP Address</th>
        </tr>
        <asp:Repeater ID="TableRepeater" runat="server" >       
            <ItemTemplate>
                <tr>
                    <td><%#Container.DataItem("dateTime")%></td>
                    <td><%#Container.DataItem("Page")%></td>
                    <td>::LOCATION</td>
                    <td><%#Container.DataItem("IPAddress")%></td>
                </tr>
            </ItemTemplate>
        </asp:Repeater>     
    </table> 

我已經看到了許多其他有關如何在表中創建轉發器的示例,但這是唯一可以實際加載頁面的示例。

然后,我創建該類的arraylist:

public class pageViews
    {
        public string dateTime {get; set;}
        public string IPAddress {get; set;}
        public string Page {get; set;}
        public string Location {get; set;}
    }

並填充它。 接下來,我嘗試通過以下方式將arrylist綁定到表:

    TableRepeater.Datasource = pviews;
    TableRepeater.Databind();

哪里:

List <pageViews> pviews = new List<pageViews>();

但是我收到以下錯誤:

 CS1061: 'System.Web.UI.WebControls.Repeater' does not contain a definition for 'Datasource' and no extension method 'Datasource' accepting a first argument of type 'System.Web.UI.WebControls.Repeater' could be found (are you missing a using directive or an assembly reference?)

這是我在項目中的所有名稱空間:

using System;
using System.Web.Configuration; 
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;

我懷疑我有很多錯誤,但是我不確定它們是什么。

我嘗試了許多教程,但似乎無濟於事。 我正在用notepad ++進行編碼,請不要建議使用VS。我正在嘗試學習如何使用智能感知。

它是DataSource ,而不是Datasource

我嘗試了許多教程,但似乎無濟於事。 我正在用notepad ++進行編碼,請不要建議使用VS。我正在嘗試學習如何使用智能感知。

首先,您需要全面閱讀它們。 我懷疑這些“大量教程”是否會將您指向Repeater的Datasource屬性...

另一方面,您說不建議使用Visual Studio Visual Studio不僅僅是一個代碼編輯器,而是一個完整的集成開發環境(IDE),而且我無法想象您將付出額外的努力來手動編譯ASP.NET應用程序,對其進行部署,..在.NET解決方案的情況下,Visual Studio足夠且完美:使用SublimeText,Notepad ++或任何其他代碼編輯器之類沒有優勢,因為您失去了許多.NET特定的代碼編輯功能。 一種是實時代碼錯誤報告,它將為您提供DataSource而不是Datasource

大多數.NET開發人員不會到問答站點來詢問拼寫錯誤的類,屬性,方法之類的東西,因為Visual Studio會提前警告您,您將因此而變得更加高效!

此外,還有Visual C#Express,Visual Web Express,現在是Visual Studio社區(所有功能都是完全免費的)...在Windows中開發C#、. NET和ASP.NET解決方案時,Notepad ++只是浪費時間。

C#區分大小寫,因此應該是DataSource

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM