0

I am trying to create an asp.net table with a repeater. Here is my code for creating the table:

    <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> 

I have seen many other examples of how to create a repeater in a table but this is the only one that will actually get the page to load.

I then create an arraylist of the class:

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

and populate it. Next I try to bind the arrylist to the table by:

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

Where:

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

But I get the following error:

 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?)

Here are all my namespaces in the project:

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

I suspect I have a number of errors, but I am not sure what they are.

I have tried numerous tutorials, but cannot seem to get any to work. I am coding in notepad++ please do not suggest to use VS I am trying to learn how to do this with intellisense.

Don't Know
  • 121
  • 2
  • 12
user4420358
  • 313
  • 1
  • 6
  • 15

2 Answers2

3

It's DataSource, not Datasource.

I have tried numerous tutorials, but cannot seem to get any to work. I am coding in notepad++ please do not suggest to use VS I am trying to learn how to do this with intellisense.

First of all, you need to read them comprehensively. I doubt that these "numerous tutorials" may be pointing you to a Repeater's Datasource property...

In the other hand, you say don't suggest Visual Studio. Visual Studio isn't just a code editor, but a complete integrated development environment (IDE), and I can't imagine the extra effort you're going to put in to manually compile an ASP.NET application, deploy it, ... In case of .NET solutions, Visual Studio is enough and perfect: there's no advantage on using something like SublimeText, Notepad++ or any other code editor, because you lose a lot of .NET-specific code editing features. One is real-time code error reporting, which would gave you that it's DataSource instead of Datasource.

Most .NET developers won't come to a Q&A site to ask for a wrongly spelled class, property, method or whatever, as Visual Studio will warn you in advance and you'll be more productive!

Also, there's a Visual C# Express, Visual Web Express, now Visual Studio Community (all absolutely free of charge)... Notepad++ is just a waste of time when developing C#, .NET and ASP.NET solutions in Windows.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
  • than you for your comments. Changing the case fixed the problem. If you read my previous posts, you will see that I have learnt many things by not using Visual studo for this application. The short cuts VS allows does not encourage meticulous coding, or understanding of some of the proecesses that go on behind the code. – user4420358 May 31 '15 at 10:00
  • 2
    @user4420358 Productivity is better than pride. This is my point. In my case, I do meticulous coding everywhere. In C#, JavaScript... but if I can have an IDE which can aid me in focusing on coding my idea rather than wasting my time in my human errors, why not using it? :D – Matías Fidemraizer May 31 '15 at 10:02
  • http://stackoverflow.com/questions/24013041/how-to-dynamically-bind-asp-net-repeater-control-to-datasource please see the answer by ewitkows – user4420358 May 31 '15 at 10:03
  • @user4420358 What has to do with this? :O – Matías Fidemraizer May 31 '15 at 10:05
  • 1
    @user4420358 Ah I see, you can add a comment to his answer. Or downvote it! – Matías Fidemraizer May 31 '15 at 10:05
  • 1
    @user4420358 BTW, why you need tutorials if there's a great documentation called MSDN !!!! – Matías Fidemraizer May 31 '15 at 10:06
1

C# is case sensitive and hence it should be DataSource

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • 2
    @MatíasFidemraizer:- As far as I think OP has written it manually and I said it is case sensitive because if that would not have been the case then it would work. Or am I missing the point? – Rahul Tripathi May 31 '15 at 09:53
  • You're missing an important point: C# coding conventions. In other words: pascal-casing, rather than case sensitiveness... – Matías Fidemraizer May 31 '15 at 09:58