I am trying to iterate through a hashtable that i have populated with objects using the repeater control.
For each iteration i wish to output the values of properties of the objects I am populating the hashtable with.
For example: -
In the webform codebehind: -Code:Class SomeClass { public String myProperty1 public String myProperty2 public SomeClass() { this.myProperty1 = "hello"; this.myProperty2 = "goodbye"; } } Class TestSome { public Hashtable myHash = new Hashtable(); public TestSome() { myHash.Add("key1", new SomeClass()); } }
ASP htmlCode:TestSome myTest = new TestSome(); this.myRepeater.DataSource = myTest.myHash; this.myRepeater.DataBind();
~ LacunaCode:<asp:repeater id=myRepeater runat="server"> <ItemTemplate> <DIV style="FLOAT: left; MARGIN-LEFT: 10px"> <asp:Label id="Label2" runat="server" Width="160px"> <!-- how do i specify that i wish to use the class's properties here? --> <%# DataBinder.Eval(Container.DataItem, "myProperty1") %> <%# DataBinder.Eval(Container.DataItem, "myProperty2") %> </asp:Label> </DIV> </ItemTemplate> </asp:repeater>




Reply With Quote