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("fir st_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.Sql Client" %>
<script runat="server">
Sub Page_Load(Obj As Object, E As EventArgs)
'Set up connection
'Dim myConnection As String = ConfigurationSettings.AppS ettings.It em("myConn ection")
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(ConnectionSt ring)
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").D efaultView
DataBind()
End Sub
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
<%@ Import Namespace="System.data" %>
<%@ Import Namespace="System.data.Sql
<script runat="server">
Sub Page_Load(Obj As Object, E As EventArgs)
'Set up connection
'Dim myConnection As String = ConfigurationSettings.AppS
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(ConnectionSt
Dim myCommand as New SqlDataAdapter(CommandText
'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
DataBind()
End Sub
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.FieldVal ue("Date_A quired", 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.FieldVal ue("Last_C ontact", Container)).ToString("d") %></td>
<td width="0"><div align="right"><span style="color: #0066FF"><span style="color: #0066FF"><a href="/_intranet/offices/r esidential /leads/vie wDetails.a spx">Detai ls</a></sp an></span> </div></td >
<td bgcolor="#E0E0E0" class="Basic_info_text"><d iv align="center"><a href="/_intranet/offices/r esidential /leads/edi tLead.aspx ">Edit</a> </div></td>
</tr>
</ItemTemplate>
</ASP:Repeater>
</form>
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.FieldVal
<td width="110"><%# ds.FieldValue("first_name"
<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 width="100"><%# DateTime.Parse(ds.FieldVal
<td width="0"><div align="right"><span style="color: #0066FF"><span style="color: #0066FF"><a href="/_intranet/offices/r
<td bgcolor="#E0E0E0" class="Basic_info_text"><d
</tr>
</ItemTemplate>
</ASP:Repeater>
</form>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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!
Cheers,
Dietmar