Repeater binding array, hash table, dictionary arraylist/hashtable,dictionary to DataSource

Source: Internet
Author: User

The original Published time: 2009-11-19--from my Baidu article [imported by moving tools]

repeater binding arrays, hash tables, dictionaries
DataSource for Arraylist/hashtable,dictionary, example

Default7.aspx Front Page:

<%@ page language= "C #" autoeventwireup= "true" codefile= "Default7.aspx.cs" inherits= "Default7"%>

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>http://hi.baidu.com/handboy</title>
<body>
<form id= "Form1" runat= "Server" >
<div>
Binding arrays
<ul>
<asp:repeater id= "Reparray" runat= "Server" >
<ItemTemplate>
<li>
<% #Container. DataItem%>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
Binding Hashtable
<ul>
<asp:repeater id= "Rephash" runat= "Server" >
<ItemTemplate>
<li>
key:<% #Eval ("key")%>,value:<% #Eval ("Value")%>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>

</div>
</form>
</body>

Default7.cs background page:

Using System;
Using System.Web.UI.WebControls;
Using System.Collections;

public partial class Default7:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
if (! IsPostBack)
{
Bindarray ();//bound array
Bindhashtable ();//bind hash table, bind dictionary<> as hash table
}

}

protected void Bindarray ()
{
ArrayList arr = new ArrayList ();
Arr. ADD ("arr11111111111");
Arr. ADD ("arr22222222222");
Arr. ADD ("arr33333333333");
Arr. ADD ("arr44444444444");

Reparray.datasource = arr;
Reparray.databind ();
}

protected void bindhashtable ()
{
Hashtable hash = new Hashtable ();
Hash. ADD (One, "hash11111111111");
Hash. ADD ("hash22222222222");
Hash. ADD ("hash33333333333");
Hash. ADD ("hash44444444444");

Rephash.datasource = hash;
Rephash.databind ();
}

}

Repeater binding array, hash table, dictionary arraylist/hashtable,dictionary to DataSource

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.