473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Need help with Repeater data binding question...

hi there,

i have a page with a repeater that is populated with my function called
GetList, that returns an arraylist of my custom object, lets say its called
Products{ProductID, Description, Price}

Now, if the datasource of the repeater is something like DataSet or
SQLDataReader and i'm returning the records, not the arraylist of "Products"
objects, in the aspx code i can use <%#
Container.DataItem("ProductID")%>....

How can i show the data in this forn <%# Container.Dataitem.....etc.%so i
can read the Property value, eg. Products.Description, or Products.Price??

thanks for anyone's help.
Paul

Nov 15 '06 #1
6 1269
Well, i'm not sure why people are still using ArrayList for
datasources, but you would be having a much easier time if you used
something typesafe, like Collection<Productor List<Product>

The reason the databinder evaluations are failing is because it has no
idea what kind of type is stored in the arraylist, since theyre only
stored as objects.
On Nov 15, 10:37 am, "Milsnips" <milsn...@hotmail.comwrote:
hi there,

i have a page with a repeater that is populated with my function called
GetList, that returns an arraylist of my custom object, lets say its called
Products{ProductID, Description, Price}

Now, if the datasource of the repeater is something like DataSet or
SQLDataReader and i'm returning the records, not the arraylist of "Products"
objects, in the aspx code i can use <%#
Container.DataItem("ProductID")%>....

How can i show the data in this forn <%# Container.Dataitem.....etc.%so i
can read the Property value, eg. Products.Description, or Products.Price??

thanks for anyone's help.
Paul
Nov 15 '06 #2
The databinding expressions are pretty smart..

you can actually do:

<%# DataBinder.Eval(Container.DataItem "Description") % and it'll work (or
the short-hand Eval in 2.0)

you could always cast it directly:

<%# ((Product)Container.DataItem).Description %>

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Milsnips" <mi******@hotmail.comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
hi there,

i have a page with a repeater that is populated with my function called
GetList, that returns an arraylist of my custom object, lets say its
called Products{ProductID, Description, Price}

Now, if the datasource of the repeater is something like DataSet or
SQLDataReader and i'm returning the records, not the arraylist of
"Products" objects, in the aspx code i can use <%#
Container.DataItem("ProductID")%>....

How can i show the data in this forn <%# Container.Dataitem.....etc.%so
i can read the Property value, eg. Products.Description, or
Products.Price??

thanks for anyone's help.
Paul

Nov 15 '06 #3
hi there,

i tried them both, with no success..
i used this line: <%# DataBinder.Eval(Container.DataItem, "Comment") %>

my error returned is: Exception Details: System.Web.HttpException:
DataBinder.Eval: 'Kolesino2006.PhotoAlbum+Photo' does not contain a property
with the name CommentID.

my class is called Photo, and it has readonly propertyies CommentID,
Comment, and so on.

thanks,
Paul
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
netwrote in message news:Oa**************@TK2MSFTNGP06.phx.gbl...
The databinding expressions are pretty smart..

you can actually do:

<%# DataBinder.Eval(Container.DataItem "Description") % and it'll work
(or the short-hand Eval in 2.0)

you could always cast it directly:

<%# ((Product)Container.DataItem).Description %>

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Milsnips" <mi******@hotmail.comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
>hi there,

i have a page with a repeater that is populated with my function called
GetList, that returns an arraylist of my custom object, lets say its
called Products{ProductID, Description, Price}

Now, if the datasource of the repeater is something like DataSet or
SQLDataReader and i'm returning the records, not the arraylist of
"Products" objects, in the aspx code i can use <%#
Container.DataItem("ProductID")%>....

How can i show the data in this forn <%# Container.Dataitem.....etc.%so
i can read the Property value, eg. Products.Description, or
Products.Price??

thanks for anyone's help.
Paul


Nov 15 '06 #4
Is it a property or a field???
public string CommentID

or

public string CommentId
{
get {return _commentId;}
}
?

The 1st won't work...

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Milsnips" <mi******@hotmail.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
hi there,

i tried them both, with no success..
i used this line: <%# DataBinder.Eval(Container.DataItem, "Comment") %>

my error returned is: Exception Details: System.Web.HttpException:
DataBinder.Eval: 'Kolesino2006.PhotoAlbum+Photo' does not contain a
property with the name CommentID.

my class is called Photo, and it has readonly propertyies CommentID,
Comment, and so on.

thanks,
Paul
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
netwrote in message news:Oa**************@TK2MSFTNGP06.phx.gbl...
>The databinding expressions are pretty smart..

you can actually do:

<%# DataBinder.Eval(Container.DataItem "Description") % and it'll work
(or the short-hand Eval in 2.0)

you could always cast it directly:

<%# ((Product)Container.DataItem).Description %>

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Milsnips" <mi******@hotmail.comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl. ..
>>hi there,

i have a page with a repeater that is populated with my function called
GetList, that returns an arraylist of my custom object, lets say its
called Products{ProductID, Description, Price}

Now, if the datasource of the repeater is something like DataSet or
SQLDataReader and i'm returning the records, not the arraylist of
"Products" objects, in the aspx code i can use <%#
Container.DataItem("ProductID")%>....

How can i show the data in this forn <%# Container.Dataitem.....etc.%>
so i can read the Property value, eg. Products.Description, or
Products.Price??

thanks for anyone's help.
Paul



Nov 15 '06 #5

so photo is an inner class to PhotoAlbum?

when you say readonly property, do mean a property with only a getter
or are you attempting to bind directly to a public field?

Milsnips wrote:
hi there,

i tried them both, with no success..
i used this line: <%# DataBinder.Eval(Container.DataItem, "Comment") %>

my error returned is: Exception Details: System.Web.HttpException:
DataBinder.Eval: 'Kolesino2006.PhotoAlbum+Photo' does not contain a property
with the name CommentID.

my class is called Photo, and it has readonly propertyies CommentID,
Comment, and so on.

thanks,
Paul
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
netwrote in message news:Oa**************@TK2MSFTNGP06.phx.gbl...
The databinding expressions are pretty smart..

you can actually do:

<%# DataBinder.Eval(Container.DataItem "Description") % and it'll work
(or the short-hand Eval in 2.0)

you could always cast it directly:

<%# ((Product)Container.DataItem).Description %>

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Milsnips" <mi******@hotmail.comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
hi there,

i have a page with a repeater that is populated with my function called
GetList, that returns an arraylist of my custom object, lets say its
called Products{ProductID, Description, Price}

Now, if the datasource of the repeater is something like DataSet or
SQLDataReader and i'm returning the records, not the arraylist of
"Products" objects, in the aspx code i can use <%#
Container.DataItem("ProductID")%>....

How can i show the data in this forn <%# Container.Dataitem.....etc.%so
i can read the Property value, eg. Products.Description, or
Products.Price??

thanks for anyone's help.
Paul
Nov 15 '06 #6
Hi,

yes it is a declared property, as such:
Private _comment As String

ReadOnly Property Comment() As String
Get
Return _comment
End Get
End Property

And to the other question from "kferron", yes its a class within another, so
"PhotoAlbum.Photo"

Also, if i just do <%# Container.DataItem%it returns me
"mynamespace.PhotoAlbum+Photo" so it can see the object in the dataitem i
guess.

regards,
Paul
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
netwrote in message news:uf**************@TK2MSFTNGP06.phx.gbl...
Is it a property or a field???
public string CommentID

or

public string CommentId
{
get {return _commentId;}
}
?

The 1st won't work...

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Milsnips" <mi******@hotmail.comwrote in message
news:ur**************@TK2MSFTNGP04.phx.gbl...
>hi there,

i tried them both, with no success..
i used this line: <%# DataBinder.Eval(Container.DataItem, "Comment") %>

my error returned is: Exception Details: System.Web.HttpException:
DataBinder.Eval: 'Kolesino2006.PhotoAlbum+Photo' does not contain a
property with the name CommentID.

my class is called Photo, and it has readonly propertyies CommentID,
Comment, and so on.

thanks,
Paul
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
netwrote in message news:Oa**************@TK2MSFTNGP06.phx.gbl...
>>The databinding expressions are pretty smart..

you can actually do:

<%# DataBinder.Eval(Container.DataItem "Description") % and it'll work
(or the short-hand Eval in 2.0)

you could always cast it directly:

<%# ((Product)Container.DataItem).Description %>

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Milsnips" <mi******@hotmail.comwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl.. .
hi there,

i have a page with a repeater that is populated with my function called
GetList, that returns an arraylist of my custom object, lets say its
called Products{ProductID, Description, Price}

Now, if the datasource of the repeater is something like DataSet or
SQLDataReader and i'm returning the records, not the arraylist of
"Products" objects, in the aspx code i can use <%#
Container.DataItem("ProductID")%>....

How can i show the data in this forn <%# Container.Dataitem.....etc.%>
so i can read the Property value, eg. Products.Description, or
Products.Price??

thanks for anyone's help.
Paul





Nov 15 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Donald Williamson | last post by:
I have a DataReader that I am binding to a Repeater control. In the DataReader, I have two fields: 'Name1' and 'Name2' 'Name1' will always have a person's name. Name2 periodically has a person's...
2
by: Paul K | last post by:
I'm having a problem getting the data binding to work with the repeater control. Here's the code for the code-behind class private void Page_Load(object sender, System.EventArgs e if...
1
by: Sparhawk | last post by:
I ran into troubles binding my repeater controls in Page_PreRender. The problem is that the Repeater_ItemCommand does not fire if the control is bound in Page_PreRender. It works fine if I am...
1
by: Raed Sawalha | last post by:
Hello: i have a UserControl i created. for datarow in my dataset i want to display one of these controls on my page. do i want to use a repeater control to do this? how do i pass a datarow to...
2
by: Colin Nicholls | last post by:
Platform: ASP.NET 1.1 I have a repeater nested inside another repeater. My outer repeater is looping fine. I am manually binding the inner repeater to a DataReader obtained from another...
4
by: Alan Silver | last post by:
Hello, I'm trying to use an ArrayList to do data binding, but am getting an error I don't understand. I posted this in another thread, but that was all confused with various other problems,...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
1
by: jl817cn | last post by:
It's strange. The page is using master page, the repeater control is placed in contentplaceholder. In repeater Itemtemplate, there are several labels and textboxes, the value of textboxes is...
5
by: DotNetNewbie | last post by:
Hi, It is not possible to bind a Generic.List collection to a repeater I guess huh? I am getting this error: An invalid data source is being used for rpCategories. A valid data source must...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.