This example shows you how to use data binding with Eiffel.
<html>
<head>
<script language="Eiffel" runat="server">
page_load (sender: SYSTEM_OBJECT; e: EVENT_ARGS) is
-- feature performed on page load.
require
non_void_sender: sender /= Void
non_void_e: e /= Void
local
h: HASHTABLE
do
if not page.is_post_back then
create h.make
h.add (("key1").to_cil, ("value1").to_cil)
h.add (("key2").to_cil, ("value2").to_cil)
h.add (("key3").to_cil, ("value3").to_cil)
my_data_list.set_data_source (h)
my_data_list.data_bind
end
end
data_item (container: WEB_DATA_LIST_ITEM): DICTIONARY_ENTRY is
-- Retrieve container.data_item.
require
non_void_container: container /= Void
do
Result ?= container.data_item
ensure
non_void_result: Result /= Void
end
</script>
</head>
<body>
<h3><font face="Verdana">DataBinding to a Hashtable</font></h3>
<form runat=server>
<asp:DataList id="my_data_list" runat="server"
BorderColor="black"
BorderWidth="1"
GridLines="Both"
CellPadding="4"
CellSpacing="0" >
<ItemTemplate>
<%# (data_item (container)).key %> :
<%# (data_item (container)).value %>
</ItemTemplate>
</asp:DataList>
</form>
</body>
Here is the output:
