?
Solved

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

Posted on 2004-11-24
5
Medium Priority
?
215 Views
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 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
0
Comment
Question by:brooksreese
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:ddetering
ID: 12672056
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
0
 
LVL 1

Author Comment

by:brooksreese
ID: 12672112
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>
0
 
LVL 1

Accepted Solution

by:
ddetering earned 500 total points
ID: 12672275
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!)
0
 
LVL 1

Author Comment

by:brooksreese
ID: 12674258
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
0
 
LVL 1

Expert Comment

by:ddetering
ID: 12674374
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!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

807 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