Can't display container Items (ASP.NET - VB)

Posted on 2004-11-24
Last Modified: 2008-02-01
I have a repeater control on my webpage called Repeater1.  I am going to use it to repeat information in my containers, but I can not even get them to display data.The way I am using the container is like this:  <%#Container.DataItem("first_name")%>  

THe problem is, when I input ANY container into the page, the following error comes up:

Compiler Error Message: BC30456: 'DataItem' is not a member of 'System.Web.UI.Control'.

As you can see, I have imported the namespace but still no luck.

The funny thing is, I copied this exact code from a page that was working and it won't work on this new page...  The code has worked previously - am I just missing something here??

My Code:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Import Namespace="" %>
<%@ Import Namespace="" %>

<script runat="server">

Sub Page_Load(Obj As Object, E As EventArgs)

            'Set up connection
            'Dim myConnection As String = ConfigurationSettings.AppSettings.Item("myConnection")
            Dim ConnectionString As String = "server=(local);Initial Catalog=my_db;User ID=sa;Password=mypass;"
            Dim CommandText as String = "SELECT Lead_ID, first_name, last_name, Address1, City, ""State"", Zip, Date_Aquired, Last_Contact FROM dbo.tbl_residential_leads"
            'Open Connection
            Dim myConnection As New SqlConnection(ConnectionString)
            Dim myCommand as New SqlDataAdapter(CommandText, MyConnection)
            'Fill Dataset
            Dim ds as New DataSet()
            myCommand.Fill(ds, "tbl_residential_leads")
            'Select data view and bind to server control


Please help before I throw my computer out of the window...

            Repeater1.DataSource = ds.Tables("tbl_residential_leads").DefaultView
End Sub
Question by:brooksreese
    LVL 1

    Expert Comment

    We will have to see your repeater control code - in particular, where you are placing the <%#Container.DataItem("first_name")%> piece. I am not too familiar with repeaters but with datagrids - I think they work similarly, so maybe I will be able to help.
    LVL 1

    Author Comment

    I have tried this with and without the <form runat="server"> tags but nothing seems to work.  Does this give you any idea to the problem?

    Oh, I have tried this without the repeater as well, no luck either way.

                                                                  <form runat="Server">
                                              <ASP:Repeater runat="server" id="Repeater1">
                                                  <tr bgcolor="#E0E0E0" class="Basic_info_text">
                                                      <td width="100"><%# DateTime.Parse(ds.FieldValue("Date_Aquired", Container)).ToString("d") %></td>
                                                      <td width="110"><%# ds.FieldValue("first_name", Container) %><%# ds.FieldValue("last_name", Container) %></td>
                                                      <td width="150" bgcolor="#E0E0E0"><%# ds.FieldValue("Address1", Container) %></td>
                                                      <td width="110"><%# ds.FieldValue("City", Container) %><%# ds.FieldValue("State", Container) %>.</td>
                                                      <td width="100">814-777-8818</td>
                                                      <td width="100"><%# DateTime.Parse(ds.FieldValue("Last_Contact", Container)).ToString("d") %></td>
                                                      <td width="0"><div align="right"><span style="color: #0066FF"><span style="color: #0066FF"><a href="/_intranet/offices/residential/leads/viewDetails.aspx">Details</a></span></span></div></td>
                                                      <td bgcolor="#E0E0E0" class="Basic_info_text"><div align="center"><a href="/_intranet/offices/residential/leads/editLead.aspx">Edit</a> </div></td>
    LVL 1

    Accepted Solution

    I am not sure whether I can help you - it is getting late and tomorrow starts the family weekend... Anyway, I have never used your syntax of binding the data as in your last post. I have used
    <%# DataBinder.Eval(container.dataitem, "price", "{0:c}")%> (great for formatting) and
    <%# container.dataitem("ticket_name")%> (the way from your initial post)
    Since you had bound the data to the repeater, you should not need to reference the dataset in your repeater control code, I would think.

    Good luck! (and Happy Thanksgiving!)
    LVL 1

    Author Comment

    Well, I don't know what to tell you.  I worked on this one problem for about four hours last night and I could not find one error.  Usually I do something dumb like leaving off an %> at the end of some code - but that is obvious.  The server immediately tells you small problems like that, and how to correct them.  This time was different.  I don't know exactly what it was, but you fixed it.  I deleted all of my container place holders and pasted in your <%# container.dataitem("ticket_name")%> (replacing ticket_name where needed, of course) code...  Some how it worked.  Maybe a combination of a good night's sleep and yoru help got this problem solved.

    Thank you so much, I can continue with this project now. :)

    have a GREAT thanksgiving!!!

    LVL 1

    Expert Comment

    Thanks for the points! I agree with you, however, that it really would be nice what fixed it, but some things are not meant to be known... Cheers!

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    This video discusses moving either the default database or any database to a new volume.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now