Hello folks,
How do I bind an array to a repeater?
or bind an array to a hyperlink (which is repeated inside a
repeater) ?
I get this message:
Compiler Error Message: BC30456: 'DataItem' is
not a member of 'System.Web.UI. Control'.
for line below that begins with <li>
This is my simplified example code. I have included 2 examples
both of which fail.
+++ +++ +++ +++
<Script Runat="Server">
Sub Page_Load()
Dim aryDates() As String = {"2004-07-04", "2004-07-05",
"2004-07-06"}
rptRHS_Menu.Dat aSource = aryDates
rptRHS_Menu.Dat aBind()
End Sub
</Script>
<html>
<body>
<asp:Repeater
ID="rptRHS_Menu "
Runat="Server" />
<ItemTemplate >
<li><a href="<%# String.Concat( Container.DataI tem,
".html") %>"><%# Container.DataI tem %></a></li>
</ItemTemplate>
</asp:Repeater>
</body>
</html>
+++ +++ +++ +++
<Script Runat="Server">
Sub Page_Load()
Dim aryDates As ArrayList
aryDates = New ArrayList
aryDates.Add ("2004-07-04")
aryDates.Add ("2004-07-05")
aryDates.Add ("2004-07-06")
aryDates.Revers e
rptRHS_Menu2.Da taSource = aryDates
rptRHS_Menu2.Da taBind()
End Sub
</Script>
<html>
<body>
<form Runat="Server">
<asp:Repeater
ID="rptRHS_Menu 2"
Runat="Server" />
<ItemTemplate >
<li>
<a href='<%# String.Format( "{0}.html",
Container.DataI tem ) %>'><%# String.Format( "{0}",
Container.DataI tem) %></a>
</ItemTemplate>
</asp:Repeater>
</form>
</body>
</html> 6 6634
Oh my God. I've been told I can't do it. I have to put the data
into a hash table and add that to the array. Like this:
Surely there is a simpler way. Why can't I just refer to the
bound array as Container.DataI tem(0) ?
I'm sure I've seen examples like that.
Here is the solution that's been indicated to me. There must be
a simpler way than this:
++ ++ ++ ++
<%@ Page Language="VB" %>
<script runat="server">
Function Add2Hash(dtd As String) As HashTable
Dim hshDates As HashTable
hshDates = New HashTable()
hshDates.Add("D ate", dtd)
Return hshDates
End Function
Sub Page_Load(sende r as Object, e as EventArgs)
Dim aryDates As ArrayList
aryDates = New ArrayList
aryDates.Add(Ad d2Hash("2004-07-04"))
aryDates.Add(Ad d2Hash("2004-07-05"))
aryDates.Add(Ad d2Hash("2004-07-06"))
aryDates.Revers e
rptRHS_Menu3.Da taSource = aryDates
rptRHS_Menu3.Da taBind()
End Sub
</script>
<html>
<head>
</head>
<body>
<form Runat="Server">
<ul>
<asp:Repeater id="rptRHS_Menu 3" Runat="Server">
<ItemTemplate >
<li><a href='<%# String.Format(" {0}.html",
Container.DataI tem.Item("Date" )) %>'><%#
Container.DataI tem.Item("Date" ) %></a></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</form>
</body>
</html>
Oh my God. I've been told I can't do it. I have to put the data
into a hash table and add that to the array. Like this:
Surely there is a simpler way. Why can't I just refer to the
bound array as Container.DataI tem(0) ?
I'm sure I've seen examples like that.
Here is the solution that's been indicated to me. There must be
a simpler way than this:
++ ++ ++ ++
<%@ Page Language="VB" %>
<script runat="server">
Function Add2Hash(dtd As String) As HashTable
Dim hshDates As HashTable
hshDates = New HashTable()
hshDates.Add("D ate", dtd)
Return hshDates
End Function
Sub Page_Load(sende r as Object, e as EventArgs)
Dim aryDates As ArrayList
aryDates = New ArrayList
aryDates.Add(Ad d2Hash("2004-07-04"))
aryDates.Add(Ad d2Hash("2004-07-05"))
aryDates.Add(Ad d2Hash("2004-07-06"))
aryDates.Revers e
rptRHS_Menu3.Da taSource = aryDates
rptRHS_Menu3.Da taBind()
End Sub
</script>
<html>
<head>
</head>
<body>
<form Runat="Server">
<ul>
<asp:Repeater id="rptRHS_Menu 3" Runat="Server">
<ItemTemplate >
<li><a href='<%# String.Format(" {0}.html",
Container.DataI tem.Item("Date" )) %>'><%#
Container.DataI tem.Item("Date" ) %></a></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</form>
</body>
</html>
Zenobia:
The code you posted in your original example works fine for me.
Perhaps you could post the complete code as the error must be
somewhere else.
I assure you it is quite possible to bind to an array or an ArrayList.
--
Scott http://www.OdeToCode.com
On Tue, 06 Jul 2004 14:29:33 +0100, Zenobia
<6.**********@s pamgourmet.com> wrote: Oh my God. I've been told I can't do it. I have to put the data into a hash table and add that to the array. Like this:
Surely there is a simpler way. Why can't I just refer to the bound array as Container.DataI tem(0) ?
I'm sure I've seen examples like that.
Here is the solution that's been indicated to me. There must be a simpler way than this:
++ ++ ++ ++ <%@ Page Language="VB" %> <script runat="server">
Function Add2Hash(dtd As String) As HashTable Dim hshDates As HashTable hshDates = New HashTable() hshDates.Add("D ate", dtd) Return hshDates End Function
Sub Page_Load(sende r as Object, e as EventArgs)
Dim aryDates As ArrayList aryDates = New ArrayList
aryDates.Add(Ad d2Hash("2004-07-04")) aryDates.Add(Ad d2Hash("2004-07-05")) aryDates.Add(Ad d2Hash("2004-07-06"))
aryDates.Revers e
rptRHS_Menu3.Da taSource = aryDates rptRHS_Menu3.Da taBind()
End Sub
</script>
<html> <head> </head> <body> <form Runat="Server"> <ul> <asp:Repeater id="rptRHS_Menu 3" Runat="Server"> <ItemTemplate > <li><a href='<%# String.Format(" {0}.html", Container.Data Item.Item("Date ")) %>'><%# Container.Data Item.Item("Date ") %></a></li> </ItemTemplate> </asp:Repeater> </ul> </form> </body> </html>
Zenobia:
The code you posted in your original example works fine for me.
Perhaps you could post the complete code as the error must be
somewhere else.
I assure you it is quite possible to bind to an array or an ArrayList.
--
Scott http://www.OdeToCode.com
On Tue, 06 Jul 2004 14:29:33 +0100, Zenobia
<6.**********@s pamgourmet.com> wrote: Oh my God. I've been told I can't do it. I have to put the data into a hash table and add that to the array. Like this:
Surely there is a simpler way. Why can't I just refer to the bound array as Container.DataI tem(0) ?
I'm sure I've seen examples like that.
Here is the solution that's been indicated to me. There must be a simpler way than this:
++ ++ ++ ++ <%@ Page Language="VB" %> <script runat="server">
Function Add2Hash(dtd As String) As HashTable Dim hshDates As HashTable hshDates = New HashTable() hshDates.Add("D ate", dtd) Return hshDates End Function
Sub Page_Load(sende r as Object, e as EventArgs)
Dim aryDates As ArrayList aryDates = New ArrayList
aryDates.Add(Ad d2Hash("2004-07-04")) aryDates.Add(Ad d2Hash("2004-07-05")) aryDates.Add(Ad d2Hash("2004-07-06"))
aryDates.Revers e
rptRHS_Menu3.Da taSource = aryDates rptRHS_Menu3.Da taBind()
End Sub
</script>
<html> <head> </head> <body> <form Runat="Server"> <ul> <asp:Repeater id="rptRHS_Menu 3" Runat="Server"> <ItemTemplate > <li><a href='<%# String.Format(" {0}.html", Container.Data Item.Item("Date ")) %>'><%# Container.Data Item.Item("Date ") %></a></li> </ItemTemplate> </asp:Repeater> </ul> </form> </body> </html>
On Tue, 06 Jul 2004 11:02:07 -0400, Scott Allen
<bitmask@[nospam].fred.net> wrote: Zenobia:
The code you posted in your original example works fine for me. Perhaps you could post the complete code as the error must be somewhere else.
I assure you it is quite possible to bind to an array or an ArrayList.
Thanks, but I think you must've fixed my code error when you got
it to work.
The error was due to an improperly closed <asp:repeater > tag.
I'm closing it here:
<asp:Repeater
ID="rptRHS_Menu "
Runat="Server" />
and including a </asp:Repeater> below that! The example should
be changed to
<asp:Repeater
ID="rptRHS_Menu "
Runat="Server">
for it to work.
The other 'solution' I posted in reply to this post was over
complex. I don't need the hash table.
Ah, yes. I had copied out just the text inside of <ItemTemplate >.
On Tue, 06 Jul 2004 18:41:25 +0100, Zenobia
<6.**********@s pamgourmet.com> wrote: On Tue, 06 Jul 2004 11:02:07 -0400, Scott Allen <bitmask@[nospam].fred.net> wrote:
Zenobia:
The code you posted in your original example works fine for me. Perhaps you could post the complete code as the error must be somewhere else.
I assure you it is quite possible to bind to an array or an ArrayList.
Thanks, but I think you must've fixed my code error when you got it to work.
The error was due to an improperly closed <asp:repeater > tag.
--
Scott http://www.OdeToCode.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Frank |
last post by:
Hi alll,
How can I bind a dynamically created dataTable to a repeater? I do not know
the number of columns and the column names at design time. I try to do the
same thing as for datagrid:
Repeater1.DataSource = values;
Repeater1.DataBind();
but it does not return anything.
Thanks.
|
by: timmso |
last post by:
I got this sample of code from Mike Moore in response to my question of how
I create clickable links from a data source.
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl='<%#
"http://localhost/ngrid1/repeater.aspx?a=" & Container.DataItem("au_lname")
%>'>'<%#...
|
by: AFN |
last post by:
I need to manually create the data to be shown in a datagrid (or some data
table object). Should I create an array and bind the array to the
datagrid OR should I create a temporary dataset and bind that to the
datagrid? I have never done either (usually I get a recordset from a
stored procedure and bind results directly). I also don't...
|
by: A Traveler |
last post by:
Hi,
I have a custom collection class i wrote, LineItemsCollection, which is a
strongly typed collection of objects of my LineItem class.
The LineItem class is a simple class with just a couple properties, ProdID,
Description, Quantity and UPC. 3 strings and a long.
The LineItemsCollection class inherits from...
|
by: Jaybuffet |
last post by:
a custom object. Similar to how I bind a collection of objects to a
repeater. Is there a way to bind a single object to a Table? I could use a
repeater, but seems over kill for a single object.
Thanks for any help.
| |
by: JP2006 |
last post by:
I'm having an issue with a control I'm writing to consume RSS feeds. It
gets a feed via a querystring parameter and sticks it in a dataset. I
then use the dataset to write out the feed title and description then
specifiy a specific table within the dataset (the one with the actual
items) to bind to a repeater control.
The problem is that not...
|
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= |
last post by:
Hi;
I have a Repeater control where in my code-behind I call:
rptrProducts.DataSource = cart.CartItems;
rptrProducts.DataBind();
And then in the aspx file I have:
<asp:TextBox ID="txtQuantity" Text='<%# Eval("Quantity") %>' runat="server"
Columns="3" />
|
by: Pieter |
last post by:
Hi,
I want to bind a proeprty of a child object to a DataGridView, but it
doesn't work.
For instance:
Imagen that I have an object Company, and this object company has a child
object Address.
Address has a property Street.
|
by: akshalika |
last post by:
Hi,
I have a repeater control. it dynamically bind textbox or dropdown base on some condition. i want to bind required field validator dynamically for validate textbox or dropdown.
here is my aspx design
<asp:Repeater ID="repeaterItemAttribute" runat="server" OnItemDataBound="repeaterItemAttribute_ItemDataBound">
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |