aspx_professional thread: Cannot use Container.DataItem.Key to access hashtable key?
The compiler returns: 'object' does not contain a definition for "key"
What am I doing wrong here?
Very simple snippet:
<html>
<head>
<script language="C#" runat="server">
public void Page_Load(Object Sender, EventArgs E) {
Hashtable myHash = new Hashtable(3);
myHash.Add("Tom",1);
myHash.Add("Dick",2);
myHash.Add("Harry",3);
myDataList.DataSource = myHash;
DataBind();
}
</script>
</head>
<body>
<ASP:DataList id="myDataList" runat="server">
<ItemTemplate>
<%#Container.DataItem.Key%> <%#Container.DataItem.Value%>
</ItemTemplate>
</ASP:DataList>
</body>
</html>
Thanks!