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

Z

Zenobia

How do I bind an array, arrayList or even a stack to a repeater
containing hyperlinks.

The data structure (array, arrayList or even a stack) has dates
in ISO format "YYYY-MM-DD". The repeated hyperlinks will be
displayed, for example, in this form:

<a href='default.aspx?arc=2004-06-29'>2004-06-29</a>

or, better:

<a href='default.aspx?arc=2004-06-29'>June 29, 2004</a>

------ ------ ------ ------ ------
I get an error:
------ ------ ------ ------ ------

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

for this line:

Text='<%# Databinder.Eval((Container).DataItem) %>'

This is the Detailed Compiler Output:

target.Text = System.Convert.ToString(Container.DataItem[0])

PS 1: This page is made up of many controls and this is just one
of them. Some of the others already have Page_Load events.

PS 2: I've tried to change the line but each of the following
give the same error on the same line.

Text='<%# Container.DataItem %>'
Text='<%# Container.DataItem[0] %>'
Text='<%# (Container.DataItem)[0] %>'
Text='<%# Container.DataItem("Value") %>'
Text='<%# DataBinder.Eval( Container.DataItem[0] ) %>'
Text='<%# DataBinder.Eval( Container.DataItem("Value") ) %>'
Text='<%# DataBinder.Eval( Container.DataItem, "Value" ) %>'

PS 3: To make it easy for you I expect the ArrayList to look
something like this:

{"2004-05-19", "2004-06-29" }


------ ------ ------ ------ ------
Here is my control containing the code.
------ ------ ------ ------ ------

<%@ Import Namespace="System.IO" %>
<Script Runat="Server">

Const vbARCHIVE_FILENAME =
"2004_99_99_net-example_archive.xml"
Const vbPOST_BACK_FILE = "default.aspx"

Sub Page_Load(vbARCHIVE_FILENAME As String)

Dim aryFileNames As Array
Dim aryDates As ArrayList

Dim lenARCHIVE As Integer
Dim i As Integer
Dim fileName As String
Dim xmlFilePath As String
Dim strISODate As String

lenARCHIVE = Len(vbARCHIVE_FILENAME) - Len("2004-99-99")

xmlFilePath = Server.MapPath( "blogs/blog.xml" )
aryFileNames = Directory.GetFiles( Left(xmlFilePath,
Len(xmlFilePath)-8) )

For Each fileName in aryFileNames
If LCase(Right(fileName, lenARCHIVE)) =
Right(vbARCHIVE_FILENAME, lenARCHIVE) Then
aryDates.Add( Replace (Left(fileName, 10),"_", "-" ) )
End If
Next

rptRHS_Menu.DataSource = aryDates
rptRHS_Menu.DataBind()
End Sub

</Script>

<!-- Sidebar (RHS Menu) -->
<h6 title="older blogs">archives</h6>
<img src="images/pixel_gr.gif" height="2" width="130"><br />

<asp:Repeater
ID="rptRHS_Menu"
Runat="Server" />
<ItemTemplate>
<ASP:HyperLink
ID="lnkItem"
Text='<%# Container.DataItem[0] %>'
NavigateUrl='<%# string.Concat(vbPOST_BACK_FILE,
"?arc=", Container.DataItem[0] %>'
Runat="Server" />
</ItemTemplate>
</asp:Repeater>
<!-- END RHS Menu -->
 
Z

Zenobia

The error is due to an incorrectly closed <asp:Repeater> tag.

This tag is closed twice:

<asp:Repeater
ID="rptRHS_Menu"
Runat="Server" />

because it also has close tag </asp:Repeater> below it.

This should replace the corresponding block below:

<asp:Repeater
ID="rptRHS_Menu"
Runat="Server">
<ItemTemplate>
<ASP:HyperLink
ID="lnkItem"
Text='<%# Container.DataItem %>'
NavigateUrl='<%# string.Concat(vbPOST_BACK_FILE,
"?arc=", Container.DataItem %>'
Runat="Server" />
</ItemTemplate>
</asp:Repeater>

And a line added in Page_Load below the variable declarations:

aryDates = New ArrayList


How do I bind an array, arrayList or even a stack to a repeater
containing hyperlinks.

The data structure (array, arrayList or even a stack) has dates
in ISO format "YYYY-MM-DD". The repeated hyperlinks will be
displayed, for example, in this form:

<a href='default.aspx?arc=2004-06-29'>2004-06-29</a>

or, better:

<a href='default.aspx?arc=2004-06-29'>June 29, 2004</a>

------ ------ ------ ------ ------
I get an error:
------ ------ ------ ------ ------

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

for this line:

Text='<%# Databinder.Eval((Container).DataItem) %>'

This is the Detailed Compiler Output:

target.Text = System.Convert.ToString(Container.DataItem[0])

PS 1: This page is made up of many controls and this is just one
of them. Some of the others already have Page_Load events.

PS 2: I've tried to change the line but each of the following
give the same error on the same line.

Text='<%# Container.DataItem %>'
Text='<%# Container.DataItem[0] %>'
Text='<%# (Container.DataItem)[0] %>'
Text='<%# Container.DataItem("Value") %>'
Text='<%# DataBinder.Eval( Container.DataItem[0] ) %>'
Text='<%# DataBinder.Eval( Container.DataItem("Value") ) %>'
Text='<%# DataBinder.Eval( Container.DataItem, "Value" ) %>'

PS 3: To make it easy for you I expect the ArrayList to look
something like this:

{"2004-05-19", "2004-06-29" }


------ ------ ------ ------ ------
Here is my control containing the code.
------ ------ ------ ------ ------

<%@ Import Namespace="System.IO" %>
<Script Runat="Server">

Const vbARCHIVE_FILENAME =
"2004_99_99_net-example_archive.xml"
Const vbPOST_BACK_FILE = "default.aspx"

Sub Page_Load(vbARCHIVE_FILENAME As String)

Dim aryFileNames As Array
Dim aryDates As ArrayList

Dim lenARCHIVE As Integer
Dim i As Integer
Dim fileName As String
Dim xmlFilePath As String
Dim strISODate As String

lenARCHIVE = Len(vbARCHIVE_FILENAME) - Len("2004-99-99")

xmlFilePath = Server.MapPath( "blogs/blog.xml" )
aryFileNames = Directory.GetFiles( Left(xmlFilePath,
Len(xmlFilePath)-8) )

For Each fileName in aryFileNames
If LCase(Right(fileName, lenARCHIVE)) =
Right(vbARCHIVE_FILENAME, lenARCHIVE) Then
aryDates.Add( Replace (Left(fileName, 10),"_", "-" ) )
End If
Next

rptRHS_Menu.DataSource = aryDates
rptRHS_Menu.DataBind()
End Sub

</Script>

<!-- Sidebar (RHS Menu) -->
<h6 title="older blogs">archives</h6>
<img src="images/pixel_gr.gif" height="2" width="130"><br />

<asp:Repeater
ID="rptRHS_Menu"
Runat="Server" />
<ItemTemplate>
<ASP:HyperLink
ID="lnkItem"
Text='<%# Container.DataItem[0] %>'
NavigateUrl='<%# string.Concat(vbPOST_BACK_FILE,
"?arc=", Container.DataItem[0] %>'
Runat="Server" />
</ItemTemplate>
</asp:Repeater>
<!-- END RHS Menu -->
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top