Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: RE: Error message


Message #1 by Sam Clohesy <sam@e...> on Tue, 20 Aug 2002 13:04:30 +0100
Anyone know what all this is about (my code behind page complies just fine):


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

Source Error:

 

Line 29:     <tr>
Line 30:     <td colspan =2 class =NewsHead>
Line 31:     <h3><%# DataBinder.Eval(Container.DataItem,"TextNews") %></h3>
Line 32:     </td>
Line 33:     </tr>
 
Cheers

Sam
Message #2 by "Christopher Reed" <CReed@m...> on Tue, 20 Aug 2002 08:18:33 -0500
Sam,

Even though you do not have a lot of code here, my guesses are:

1) You are using neither a DataList, a DataGrid, nor a Repeater class;

2) You failed to DataBind to your container control;

3) This is not the statement you want to use because you are not using
a container class.

Please include more of your source code for more thorough response.

Hope this helps!

Chris

Christopher Reed
Application Analyst
Web Development Coordinator
Information Technology
City of Lubbock
creed@m...
"The oxen are slow, but the earth is patient."

>>> sam@e... 7:04:30 AM 8/20/2002 >>>
Anyone know what all this is about (my code behind page complies just
fine):


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

Source Error:

 

Line 29:     <tr>
Line 30:     <td colspan =2 class =NewsHead>
Line 31:     <h3><%# DataBinder.Eval(Container.DataItem,"TextNews")
%></h3>
Line 32:     </td>
Line 33:     </tr>
 
Cheers

Sam
Message #3 by Sam Clohesy <sam@e...> on Tue, 20 Aug 2002 14:42:03 +0100
Hi Chris thanks for getting back to me:

Here is the relevant code section (code behind)



#Region "Import Statements"
Imports System
Imports System.Web.UI
Imports System.Web.UI.Page
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Web.Mail
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.DateAndTime
Imports System.ComponentModel
Imports System.Drawing
Imports System.IO
Imports System.Text
Imports System.Web


#End Region

    Public Class SelectedRow

        Inherits Page

        Protected WithEvents DLProducts As DataList
        Protected WithEvents lUnitOnOrder As Label
        Protected WithEvents lUnitsOnOrder As Label

#Region "Connection String Declation"

    Private sSqlCon As String = "server=XXXX;database=XXXX;uid=XX;pwd=XXXXX"

#End Region

#Region "Page Loads"


        Public Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
            If Not IsPostBack Then
                Bind()
            End If
        End Sub

#End Region


#Region "Bind Data"


        Sub Bind()

            Dim sqlCon As New SqlConnection(sSqlCon)
            Dim sqlCmd As New StringBuilder()
            sqlCmd.Append("select ProductName, UnitPrice,")
            sqlCmd.Append("UnitsInStock,UnitsOnOrder,")
            sqlCmd.Append("ProductID from Products")
            Dim sda As New SqlDataAdapter(sqlCmd.ToString(), sqlCon)
            Dim ds As New DataSet()
            sda.Fill(ds, "products")
            DLProducts.DataSource = ds.Tables("Products").DefaultView
            DLProducts.DataBind()

        End Sub

        Public Sub DLProducts_ItemCommand(ByVal Sender As Object, ByVal e As
DataListCommandEventArgs)
            If e.CommandName = "select" Then
                DLProducts.SelectedIndex = e.Item.ItemIndex
                Bind()
            End If
        End Sub

#End Region



    End Class
-----Original Message-----
From: Christopher Reed [mailto:CReed@m...]
Sent: 20 August 2002 14:19
To: ASP+
Subject: [aspx] RE: Error message


Sam,

Even though you do not have a lot of code here, my guesses are:

1) You are using neither a DataList, a DataGrid, nor a Repeater class;

2) You failed to DataBind to your container control;

3) This is not the statement you want to use because you are not using
a container class.

Please include more of your source code for more thorough response.

Hope this helps!

Chris

Christopher Reed
Application Analyst
Web Development Coordinator
Information Technology
City of Lubbock
creed@m...
"The oxen are slow, but the earth is patient."

>>> sam@e... 7:04:30 AM 8/20/2002 >>>
Anyone know what all this is about (my code behind page complies just
fine):


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

Source Error:

 

Line 29:     <tr>
Line 30:     <td colspan =2 class =NewsHead>
Line 31:     <h3><%# DataBinder.Eval(Container.DataItem,"TextNews")
%></h3>
Line 32:     </td>
Line 33:     </tr>
 
Cheers

Sam

---

ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442

ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450

These books are a complete reference to the ASP.NET namespaces 
for developers who are already familiar with using ASP.NET. 
There is no trivial introductory material or useless .NET 
hype and the presentation of the namespaces, in an easy-to use 
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes, 
giving you those real-world tips that the documentation doesn't 
offer, and demonstrating complex techniques with simple 
examples.  

---
Message #4 by "Christopher Reed" <CReed@m...> on Tue, 20 Aug 2002 09:47:08 -0500
Sam,

>Line 29:     <tr>
>Line 30:     <td colspan =2 class =NewsHead>
>Line 31:     <h3><%#
DataBinder.Eval(Container.DataItem,"TextNews")%></h3>
>Line 32:     </td>
>Line 33:     </tr>

From what I can tell, line 31 needs to be in a control that is
contained by your DataList.

For example, it should like something like this:

<asp:DataList id="DataList1" 	RepeatLayout="Table"
RepeatDirection="Horizontal" RepeatColumns="5" GridLines="Both"
OnItemCreated="Item_Created"  runat="server">
	<HeaderTemplate>
		News
	</HeaderTemplate>
	<ItemTemplate>
		<%# DataBinder.Eval(Container.DataItem, "TextNews") %>
	</ItemTemplate>
</asp:DataList>

Hope this helps!

Chris

Christopher Reed
Application Analyst
Web Development Coordinator
Information Technology
City of Lubbock
creed@m...
"The oxen are slow, but the earth is patient."

>>> sam@e... 8:42:03 AM 8/20/2002 >>>
Hi Chris thanks for getting back to me:

Here is the relevant code section (code behind)



#Region "Import Statements"
Imports System
Imports System.Web.UI
Imports System.Web.UI.Page
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Web.Mail
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.DateAndTime
Imports System.ComponentModel
Imports System.Drawing
Imports System.IO
Imports System.Text
Imports System.Web


#End Region

    Public Class SelectedRow

        Inherits Page

        Protected WithEvents DLProducts As DataList
        Protected WithEvents lUnitOnOrder As Label
        Protected WithEvents lUnitsOnOrder As Label

#Region "Connection String Declation"

    Private sSqlCon As String 
"server=XXXX;database=XXXX;uid=XX;pwd=XXXXX"

#End Region

#Region "Page Loads"


        Public Sub Page_Load(ByVal Sender As Object, ByVal E As
EventArgs)
            If Not IsPostBack Then
                Bind()
            End If
        End Sub

#End Region


#Region "Bind Data"


        Sub Bind()

            Dim sqlCon As New SqlConnection(sSqlCon)
            Dim sqlCmd As New StringBuilder()
            sqlCmd.Append("select ProductName, UnitPrice,")
            sqlCmd.Append("UnitsInStock,UnitsOnOrder,")
            sqlCmd.Append("ProductID from Products")
            Dim sda As New SqlDataAdapter(sqlCmd.ToString(), sqlCon)
            Dim ds As New DataSet()
            sda.Fill(ds, "products")
            DLProducts.DataSource = ds.Tables("Products").DefaultView
            DLProducts.DataBind()

        End Sub

        Public Sub DLProducts_ItemCommand(ByVal Sender As Object, ByVal
e As
DataListCommandEventArgs)
            If e.CommandName = "select" Then
                DLProducts.SelectedIndex = e.Item.ItemIndex
                Bind()
            End If
        End Sub

#End Region



    End Class
Message #5 by Sam Clohesy <sam@e...> on Tue, 20 Aug 2002 16:24:06 +0100
Hi Chris-thanks again- I have this, for example:


 <asp:DataList ID="DLProducts" CellPadding ="0" CellSpacing ="0" Width
="750" 
    BorderWidth ="1" 
    GridLines ="Both" 
    AlternatingItemStyle-BackColor="Tan" 
    HeaderStyle-CssClass ="productsHead" 
    Font-Size ="12" 
    RepeatColumns ="1" 
    OnItemCommand ="DLProducts_ItemCommand"
    >
    <ItemTemplate>
    <table cellpadding =4 cellspacing =0 width =100>
    <tr>
    <td colspan ="2" class ="Productshead">
    <h3><%# DataBinder.Eval(Container.DataItem,"ProductName") %></h3>
    </td>

etc etc

It is probably staring me in the face!- thanks for your input

Sam



-----Original Message-----
From: Christopher Reed [mailto:CReed@m...]
Sent: 20 August 2002 15:47
To: ASP+
Subject: [aspx] RE: Error message


Sam,

>Line 29:     <tr>
>Line 30:     <td colspan =2 class =NewsHead>
>Line 31:     <h3><%#
DataBinder.Eval(Container.DataItem,"TextNews")%></h3>
>Line 32:     </td>
>Line 33:     </tr>

From what I can tell, line 31 needs to be in a control that is
contained by your DataList.

For example, it should like something like this:

<asp:DataList id="DataList1" 	RepeatLayout="Table"
RepeatDirection="Horizontal" RepeatColumns="5" GridLines="Both"
OnItemCreated="Item_Created"  runat="server">
	<HeaderTemplate>
		News
	</HeaderTemplate>
	<ItemTemplate>
		<%# DataBinder.Eval(Container.DataItem, "TextNews") %>
	</ItemTemplate>
</asp:DataList>

Hope this helps!

Chris

Christopher Reed
Application Analyst
Web Development Coordinator
Information Technology
City of Lubbock
creed@m...
"The oxen are slow, but the earth is patient."

>>> sam@e... 8:42:03 AM 8/20/2002 >>>
Hi Chris thanks for getting back to me:

Here is the relevant code section (code behind)



#Region "Import Statements"
Imports System
Imports System.Web.UI
Imports System.Web.UI.Page
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Web.Mail
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.DateAndTime
Imports System.ComponentModel
Imports System.Drawing
Imports System.IO
Imports System.Text
Imports System.Web


#End Region

    Public Class SelectedRow

        Inherits Page

        Protected WithEvents DLProducts As DataList
        Protected WithEvents lUnitOnOrder As Label
        Protected WithEvents lUnitsOnOrder As Label

#Region "Connection String Declation"

    Private sSqlCon As String 
"server=XXXX;database=XXXX;uid=XX;pwd=XXXXX"

#End Region

#Region "Page Loads"


        Public Sub Page_Load(ByVal Sender As Object, ByVal E As
EventArgs)
            If Not IsPostBack Then
                Bind()
            End If
        End Sub

#End Region


#Region "Bind Data"


        Sub Bind()

            Dim sqlCon As New SqlConnection(sSqlCon)
            Dim sqlCmd As New StringBuilder()
            sqlCmd.Append("select ProductName, UnitPrice,")
            sqlCmd.Append("UnitsInStock,UnitsOnOrder,")
            sqlCmd.Append("ProductID from Products")
            Dim sda As New SqlDataAdapter(sqlCmd.ToString(), sqlCon)
            Dim ds As New DataSet()
            sda.Fill(ds, "products")
            DLProducts.DataSource = ds.Tables("Products").DefaultView
            DLProducts.DataBind()

        End Sub

        Public Sub DLProducts_ItemCommand(ByVal Sender As Object, ByVal
e As
DataListCommandEventArgs)
            If e.CommandName = "select" Then
                DLProducts.SelectedIndex = e.Item.ItemIndex
                Bind()
            End If
        End Sub

#End Region



    End Class

---

ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442

ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450

These books are a complete reference to the ASP.NET namespaces 
for developers who are already familiar with using ASP.NET. 
There is no trivial introductory material or useless .NET 
hype and the presentation of the namespaces, in an easy-to use 
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes, 
giving you those real-world tips that the documentation doesn't 
offer, and demonstrating complex techniques with simple 
examples.  

---

  Return to Index