Bind hashtable to asp datalist (C#) : DataList « Asp Control « ASP.Net

ASP.Net
1. ADO.net Database
2. Asp Control
3. Collections
4. Components
5. Data Binding
6. Development
7. HTML Control
8. Mobile Control
9. Page
10. Request
11. Response
12. Server
13. Session Cookie
14. User Control and Master Page
15. Validation by Control
16. Validation by Function
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
ASP.Net » Asp Control » DataList 
Bind hashtable to asp datalist (C#)

<%@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>
    <%# DataBinder.Eval(Container.DataItem, "Key""<font size='1'>{0}</font>"%>
    <%# DataBinder.Eval(Container.DataItem, "Value""<font size='1'>${0:f2}</font>"%>
  </itemtemplate>
  <alternatingitemtemplate>
    <%# DataBinder.Eval(Container.DataItem, "Key""<font size='4'>{0}</font>"%>
    <%# DataBinder.Eval(Container.DataItem, "Value""<font size='4'>${0:f2}</font>"%>
  </alternatingitemtemplate>

</asp:datalist>

</body>
</html>

<script Language="C#" runat="server">

void Page_Load() {

   // create a HashTable of values to bind to
   Hashtable tabValues = new Hashtable(4);
   tabValues.Add("A"49.56);
   tabValues.Add("B"28.33);
   tabValues.Add("C"55);
   tabValues.Add("D"20.74);
   tabValues.Add("E"41.1);

   // set the DataSource property of the control to the
   // hashtable and bind it to display the values
   dlTest.DataSource = tabValues;
   dlTest.DataBind();

}

</script>

           
       
Related examples in the same category
1. Bind arrayList to asp datalist (C#)
2. item style and alternating item style for asp datalist (C#)
w__ww_._j_a__v__a_2s.__c___om | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.