本文介绍了如何在不使用数据库的情况下绑定数据列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不使用数据库的情况下绑定数据列表,就像阅读器或数据集一样,我想通过全局变量或函数绑定数据列表
How can be bind data list with out using database Like reader or data set i want to bind the data list by a global variable or function
推荐答案
<asp:datalist id="datalist" runat="server" datakeyfield="Key" xmlns:asp="#unknown">
<itemtemplate>
<asp:label runat="server" text="<%# Eval("Value") %>"></asp:label>
</itemtemplate>
</asp:datalist>
代码
Code
Dictionary<string,> dictionary = new Dictionary<string,>()
{
{"a", "aaa"},
{"b", "bbb"},
{"c", "ccc"}
};
datalist.DataSource = dictionary;
datalist.DataBind();
这篇关于如何在不使用数据库的情况下绑定数据列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!