










Code
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Dictionary<string, A> d = new Dictionary<string, A>();
d.Add("aa", new A("1", "xx"));
d.Add("bb", new A("2", "yy"));
d.Add("cc", new A("3", "zz"));
DataList1.DataSource
= d;调用示例:
Code
<asp:DataList ID="DataList1" runat="server" OnItemDataBound="DataList1_ItemDataBound">
<ItemTemplate>
<%#( (System.Collections.Generic.KeyValuePair<string, A>)(Container.DataItem)).Key %>
<%#( ((System.Collections.Generic.KeyValuePair<string, A>)(Container.DataItem)).Value as A).PKID %>
<%#( ((System.Collections.Generic.KeyValuePair<string, A>)(Container.DataItem)).Value as A).Type %>
</ItemTemplate>
</asp:DataList>
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。