Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will likely want to do something in your <em>PageLoad</em> such as:</p> <pre><code>List&lt;SomeBusinessObj&gt; MyEntityCollection = Repository.Load(); </code></pre> <p>You then can bind your entity object collection to the repeater control using the <em>DataSource</em> property of the repeater control.</p> <pre><code>rptrMyRepeater.DataSource = MyEntityCollection; </code></pre> <p>Then by calling <em>DataBind</em> on that control, your collection will become bound to that control.</p> <pre><code>rptrMyRepeater.DataBind(); </code></pre> <p>Then all you need to do is use the Repeater's databound event to apply your custom properties to the repeater's controls.</p> <pre><code>protected void rptrExample_OnItemDataBound(object Sender, RepeaterItemEventArgs Args) { if (Args.Item.ItemType == ListItemType.Item || Args.Item.ItemType == ListItemType.AlternatingItem) { SomeBusinessObj Obj = (SomeBusinessObj)Args.Item.DataItem; Label LabelControl = (Label)Args.Item.FindControl("lblSomeLabel"); LabelControl.Text = Obj.CustomProperty; } } </code></pre> <p>The <em>ItemDataBound</em> event will be called for each row item, so each time it is called you will be working on the that row item's controls and databound object.</p> <hr> <p>An alternative approach would be to directly databind within markup, not using the <em>OnItemDataBound</em> event.</p> <pre><code>&lt;asp:Label Text='&lt;%# ((MyObjects.SomeBusinessObj)Container.DataItem).CustomProperty %&gt;' runat="server" /&gt; </code></pre> <p>The direct cast avoids the call into <em>DataBinder.Eval</em>, and the overhead of reflection.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload