Link to home
Start Free TrialLog in
Avatar of brooksreese
brooksreese

asked on

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

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 system.data 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="System.data" %>
<%@ Import Namespace="System.data.SqlClient" %>



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

Brooks
            Repeater1.DataSource = ds.Tables("tbl_residential_leads").DefaultView
            
            DataBind()
      
End Sub
Avatar of ddetering
ddetering

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.
Cheers,
Dietmar
Avatar of brooksreese

ASKER

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.

Code:
-------------------------------------------------------------
                                                              <form runat="Server">
                                          <ASP:Repeater runat="server" id="Repeater1">
                                            <ItemTemplate>
                                              <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>
                                              </tr>
                                            </ItemTemplate>
                                          </ASP:Repeater>
                                                              </form>
ASKER CERTIFIED SOLUTION
Avatar of ddetering
ddetering

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!!!

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