How do i perform a databind on a web user control within a repeate

M

mike

How do i perform a databind on a web user control within a repeater or rather
how can I access the datasource that is already bound? I have a web user
control that displays a table of values (the profile of a piece of equipment)
from SQLServer. I've used a repeater on the webform since a query (i.e. by
address) against the DB may return multiple machine profiles and I want to
use the repeater to display as many machine profiles as are returned by the
DB.

for each field in on the web user control I've tried using something like
the following to access each field value:

DataBinder.Eval(Container.DataItem, "Name")
(where FIELD_NAME is the name of the column I'd like to reference.)

This method will work if I place the repeater in the web user control (and
make it public or create a property for the datasource) rather than the
webform but what I'd like to do is to create the repeater control on my
webform and then include the webusercontrol inside the repeater's item
template. However, when I do this the above method for refering to the field
value no longer works. I get error messages saying that container is not a
member of web.ui.controls. I found a semi-relavent posting which suggested I
use:

DataBinder.Eval(Container, "DataItem.FIELD_NAME")

However this does not work either. How can this be achieved?
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top