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

Discussion in 'ASP .Net' started by =?Utf-8?B?bWlrZQ==?=, May 16, 2005.

  1. 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?
    =?Utf-8?B?bWlrZQ==?=, May 16, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Olav Tollefsen
    Replies:
    2
    Views:
    1,891
    Olav Tollefsen
    Dec 29, 2004
  2. Don
    Replies:
    3
    Views:
    5,450
    Karl Seguin
    Mar 11, 2005
  3. Replies:
    9
    Views:
    312
    Peter Hansen
    Mar 3, 2005
  4. Michael
    Replies:
    0
    Views:
    221
    Michael
    Dec 29, 2003
  5. mike
    Replies:
    0
    Views:
    147
Loading...

Share This Page