views:

130

answers:

1

I want to use an asp repeater to generate the html for the items I pull back in a custom class Queue. In other words

Queue x = otherClass.getCustomClassObjects();

And then bind this to a repeater.

And on the OnRepeaterItemDataBound

assingn the html values appropriately to what is in the queue.

Is this possible ?

+1  A: 

Okay let us say you have a queue of objects of type Widget. Widget has three properties: ID, Name, Description.

Let us also say you have your repeater set up like this in your aspx/ascx file:

<asp:repeater id="rpt1" runat="server">
  <ItemTemplate>
     <%# Eval(Container.DataItem, "ID") %>
     <br />
     <%# Eval(Container.DataItem, "Name") %>
     <br />
     <%# Eval(Container.DataItem, "Description") %>
  </ItemTemplate>

In your .Net code you would have the following code somewhere:

Queue x = otherClass.getCustomerClassObjects();
rpt1.DataSource = x;
rpt1.DataBind();

In addition, here is a link that may help you further: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.itemdatabound.aspx

Have Fun!!!!

Dan Appleyard
Great intro to Repeater
JoshJordan