Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're only concerned with displaying data in your collection you could add another static method that returns your objects ReadOnlyCollection and bind to that. Alternatively you can ditch the ObjectDataSource and do it in code, something like:</p> <pre><code> var myObj = ClassName.StaticMethod(someParam); MyRepeater.DataSource = myObj.Collection; MyRepeater.DataBind(); </code></pre> <p>If you need to display both data in your class and collection, then you can add another Repeater to the ItemTemplate:</p> <pre><code>&lt;asp:objectdatasource runat="server" id="myData" selectmethod="StaticMethod" typename="ClassName"&gt; &lt;selectparameters&gt; &lt;asp:parameter name="ParamName" defaultvalue="Value" /&gt; &lt;/selectparameters&gt; &lt;/asp:objectdatasource&gt; &lt;asp:Repeater runat="server" datasourceid="myData" OnItemDataBound="Rep_ItemDataBound"&gt; &lt;ItemTemplate&gt; &lt;%# Eval("SomeProperty") %&gt; &lt;ul&gt; &lt;asp:Repeater id="RepCollection" runat="server"&gt; &lt;ItemTemplate&gt; &lt;li&gt;&lt;%# Eval("SomeCollectionProperty") %&gt;&lt;/li&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/ul&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>The ItemDataBound method would look something like:</p> <pre><code>protected void Rep_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item) { var dataItem = (ClassName)e.Item.DataItem; var innerRepeater = (Repeater)e.Item.FindControl("RepCollection"); innerRepeater.DataSource = dataItem.Collection; innerRepeater.DataBind(); } } </code></pre>
    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.
 

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