【发布时间】:2023-03-30 03:36:01
【问题描述】:
我有一个包含字符串和整数的字典,如果可能的话,我想将字典字符串和整数解析为 html 表?
protected void Page_Load(object sender, EventArgs e)
{
Dictionary<string, int> userMediaList = new Dictionary<string, int>();
userMediaList.Add("Die Hard", 5);
userMediaList.Add("Die Hard II", 3);
userMediaList.Add("Die Hard III", 2);
userMediaList.Add("Ringenes Herre", 4);
userMediaList.Add("Ringenes Herre II", 1);
userMediaList.Add("Ringenes Herre III", 5);
var sortUserMediaList = from entry in userMediaList orderby entry.Value ascending select entry;
}
所以我想要将其添加到网站上的表格中。
这样对于表格中的每个框,都会显示电影的名称和电影的评分。
【问题讨论】:
-
当然可以。这取决于您使用的技术...
-
Geez Andrei V. 仇恨怎么了.... @Winkz,您可能想看看 stackoverflow.com/questions/2274875/bind-dictionary-to-repeater ,他们将字典绑定到中继器。这可以很容易地做你想要的。
-
它在网络应用程序中吗?
-
好吧,我猜这很好:D 很好,我正在使用 foreach 循环遍历条目。只是不知道如何将每一行应用到表中的新“框”。
-
谢谢你,戴夫,我会试着读一读! Ufuk 这是一个网页,所以我想是的 :)
标签: c# html dictionary code-behind