原文发布时间为:2009-11-19 —— 来源于本人的百度文章 [由搬家工具导入]

repeater绑定数组、哈希表、字典
datasource为ArrayList/HashTable,Dictionary时,范例

Default7.aspx 前台页面:

<%@ 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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>http://hi.baidu.com/handboy</title>
</head>
<body>
<form id="form1" runat="server">
<div>
绑定数组
<hr />
<ul>
<asp:Repeater ID="repArray" runat="server">
<ItemTemplate>
<li>
<%#Container.DataItem %>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
绑定Hashtable
<hr />
<ul>
<asp:Repeater ID="repHash" runat="server">
<ItemTemplate>
<li>
Key:<%#Eval("key") %>,Value:<%#Eval("value") %>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>

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

Default7.cs 后台页面:

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();//绑定数组
BindHashtable();//绑定哈希表,绑定Dictionary<>跟哈希表一样           
}

}

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(11,"hash11111111111");
hash.Add(22,"hash22222222222");
hash.Add(33,"hash33333333333");
hash.Add(44,"hash44444444444");

repHash.DataSource = hash;
repHash.DataBind();
}

}

repeater绑定数组、哈希表、字典 ArrayList/HashTable,Dictionary为datasource的更多相关文章

  1. perl5 第九章 关联数组/哈希表

    第九章 关联数组/哈希表 by flamephoenix 一.数组变量的限制二.定义三.访问关联数组的元素四.增加元素五.创建关联数组六.从数组变量复制到关联数组七.元素的增删八.列出数组的索引和值九 ...

  2. [LeetCode] #1# Two Sum : 数组/哈希表/二分查找/双指针

    一. 题目 1. Two SumTotal Accepted: 241484 Total Submissions: 1005339 Difficulty: Easy Given an array of ...

  3. 167. 两数之和 II - 输入有序数组 + 哈希表 + 双指针

    167. 两数之和 II - 输入有序数组 LeetCode_167 题目描述 方法一:暴力法(使用哈希表) class Solution { public int[] twoSum(int[] nu ...

  4. [转]net中哈希表的使用 Hashtable

    本文转自:http://www.cnblogs.com/gsk99/archive/2011/08/28/2155988.html 以下是PetShop中DBHelper中的使用过程: //创建哈希表 ...

  5. list,arraylist,哈希表,字典,datatable的selct等等用法

    例子一.获取到list中的最大值,极其索引 List<int> ls = new List<int>();            ls.Add(1);            l ...

  6. Repeater绑定数组并显示其值

    web开发中,尤其是对于数据展示,不得不说Repeater是一个万能的控件,而且使用也很方便. 在ASP.NET中将数组绑定到Repeater中请问如何在Repeater前台页面中显示该数组的值? s ...

  7. Repeater绑定数组

    前台代码: <asp:Repeater ID="rptarry" runat="server" >         <HeaderTempla ...

  8. .net框架-字典对象 Hashtable & Dictionary<TKey,TValue> & SortedList

    字典对象: 字典对象是表示键值对的集合 字典对象有Hashtable(.net 1.0)及其泛型版本Dictionary<TKey,TValue> 字典对象还包括SortedList及其泛 ...

  9. 哈希表 -数据结构(C语言实现)

    读数据结构与算法分析 哈希表 一种用于以常数平均时间执行插入.删除和查找操作的数据结构. 但是是无序的 一般想法 通常为一个包含关键字的具有固定大小的数组 每个关键字通过散列函数映射到数组中 冲突:两 ...

随机推荐

  1. Mysql--select基础查询

    基本语法:select 查询列表 from 表名 查询列表可以是表中字段.常量值.表达式.函数:查询的结果是一个虚拟的表格. 注意: ①sql语言大小写不敏感 ②关键字不能分行或略写 ③一般书写方式为 ...

  2. 【CSS】非常简单的css实现div悬浮页面底部

    <div id="demo_div"></div> <style> #demo_div{ left:; position: fixed; bot ...

  3. 在Ubuntu下配置jdk+maven

    1.在官网上下载对应Linux版本的jdk 2.在终端输入命令将下载好的jdk解压并且转移到指定的路径如:首先执行 tar -zxvf jdk-8u181-linux-x64.tar.gz    然后 ...

  4. Codeforces Round #460 (Div. 2)-C. Seat Arrangements

    C. Seat Arrangements time limit per test1 second memory limit per test256 megabytes Problem Descript ...

  5. 数据库sql中distinct用法注意事项

    在写sql中去重复等操作,需要用到distinct. 在使用distinct的时候要注意,尤其是在有行列转换的时候.要把sql运行出来看看是不是与你想要的结果一样. 通过自己试验,distinct有从 ...

  6. oracle 基本函数

    1)字符串函数---length()函数 用于返回字符串长度  select t.name,length(t.name) from tb_person t 2)向左补全字符串---LPAD()函数 L ...

  7. loj2091 「ZJOI2016」小星星

    ref 总的来说,就是 容斥转化为点对应到点集问题. 树形 dp 解决转化后的问题. #include <iostream> #include <cstring> #inclu ...

  8. 在 Amazon AWS 搭建及部署网站:(三)开发及部署环境

    服务器已经搭建好,网站也开始运行了.那么如何方便地部署代码呢? 最基本的方式,就是使用 SFTP 向网站目录直接部署.这种方法的缺点是版本控制不便,在上传时也无法方便的比较代码变化. 用SVN来部署是 ...

  9. leetcode 【 Unique Paths 】python 实现

    题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...

  10. Linux下python升级到python-2.7.13

    下载python最新版本2.7.13并编译安装 wget https://www.python.org/ftp/python/2.7.12/Python-2.7.13.tar.xz xz -d Pyt ...