<%@Page Language="C#"%>
<html>
<body>
<asp:DataList ID="dlTest"
runat="server"
forecolor="#000000"
backcolor="#ffffff"
cellpadding="3"
gridlines="none"
width="50%" >
<itemstyle font-name="tahoma,arial,sans-serif" backcolor="#ffffff" />
<alternatingitemstyle font-name="tahoma,arial,sans-serif" backcolor="#ffff00" />
<itemtemplate>
<%# Eval("Key", "<font size='1'>{0}</font>") %>
<%# Eval("Value", "<font size='1'>${0:f2}</font>") %>
</itemtemplate>
<alternatingitemtemplate>
<%# Eval("Key", "<font size='4'>{0}</font>") %>
<%# Eval("Value", "<font size='4'>${0:f2}</font>") %>
</alternatingitemtemplate>
</asp:Datalist>
</body>
</html>
<script Language="C#" runat="server">
protected void Page_Load()
{
/*
DataList'te göstereceğimiz veriler için Hashtable nesnesi tanımlıyoruz*/
Hashtable tabValues = new Hashtable(5);
tabValues.Add("A", 49.56);
tabValues.Add("B", 28.33);
tabValues.Add("C", 55);
tabValues.Add("D", 20.74);
tabValues.Add("E", 41.1);
/*Manual olarak girdiğimiz verileri DataList'e bağlıyoruz*/
dlTest.DataSource = tabValues;
dlTest.DataBind();
}
</script>
Kaynak: http://www.forxy.net/ViewKonuDetay.aspx?KonuID=209