我使用LINQ查询泛型字典,然后使用结果作为我的ListView(WebForms)的数据源.
简化代码:
Dictionary<Guid, Record> dict = GetAllRecords();
myListView.DataSource = dict.Values.Where(rec => rec.Name == "foo");
myListView.DataBind();
Run Code Online (Sandbox Code Playgroud)
我认为这会工作,但实际上它会抛出一个System.InvalidOperationException:
ID为'myListView'的ListView必须具有实现ICollection的数据源,或者如果AllowPaging为true,则可以执行数据源分页.
为了使它工作,我不得不采取以下措施:
Dictionary<Guid, Record> dict = GetAllRecords();
List<Record> searchResults = new List<Record>();
var matches = dict.Values.Where(rec => rec.Name == "foo");
foreach (Record rec in matches)
searchResults.Add(rec);
myListView.DataSource = searchResults;
myListView.DataBind();
Run Code Online (Sandbox Code Playgroud)
在第一个例子中是否有一个小问题使它工作?
(不知道该使用什么作为这个问题的标题,随意编辑更合适的东西)
我正在考虑开发一个类似于stackoverflow的网站,但答案也可能包括图纸(原理图,在这种情况下).我希望在答案表单中有一个区域,他们可以在不需要特殊插件等的情况下制作这个原理图.
- 亚当戴维斯
我对文档库特别感兴趣,但就一般的SharePoint列表而言,任何人都可以回答以下内容......?
我不确定是使用:first
还是:eq(0)
选择器.我很确定他们总会返回相同的物体,但比另一个更快?
我相信这里的某人必须先对这些选择器进行基准测试,而且我不确定测试一个是否更快的最佳方法.
更新:这是我跑的替补席:
/* start bench */
for (var count = 0; count < 5; count++) {
var i = 0, limit = 10000;
var start, end;
start = new Date();
for (i = 0; i < limit; i++) {
var $radeditor = $thisFrame.parents("div.RadEditor.Telerik:eq(0)");
}
end = new Date();
alert("div.RadEditor.Telerik:eq(0) : " + (end-start));
var start = new Date();
for (i = 0; i < limit; i++) {
var $radeditor = $thisFrame.parents("div.RadEditor.Telerik:first");
}
end = new …
Run Code Online (Sandbox Code Playgroud) 我看了几个ASP.Net和IIS的URL重写器,并想知道其他人使用什么,以及为什么.
以下是我使用或查看过的内容:
我一直在研究AngularJS并遵循其安装步骤,但是我在运行步骤#1时遇到错误:
npm install -g karma
Run Code Online (Sandbox Code Playgroud)
这是完整的输出:
Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.
C:\Users\Travis>node --version
v0.10.18
C:\Users\Travis>python --version
Python 2.7.3
C:\Users\Travis>npm install -g karma
npm http GET https://registry.npmjs.org/karma
npm http 304 https://registry.npmjs.org/karma
npm http GET https://registry.npmjs.org/di
npm http GET https://registry.npmjs.org/socket.io
npm http GET https://registry.npmjs.org/chokidar
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/http-proxy
npm http GET https://registry.npmjs.org/colors/0.6.0-1
npm http GET https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/useragent
npm http …
Run Code Online (Sandbox Code Playgroud) 在SO 18上,Joel提到了一种算法,该算法可以根据项目的年龄和受欢迎程度对项目进行排名,它基于重力.有人发贴这个吗?C#会很可爱,但实际上任何语言(好吧,我不能做LISP)都没关系.
我在mac上运行Flex Builder 3,随着项目的增长 - 编译时间越来越长,越来越长.我正在使用一些SWC并且有相当数量的代码但是它应该不需要花费几分钟来构建并且每天都会崩溃吗?
有没有办法让TortoiseSVN(或任何其他工具)自动添加我在目录中创建的任何新.cs文件到我的工作副本,所以我不必记住我在一天结束时创建的文件?
我发现了,ScriptingJsonSerializationSection
但我不确定如何使用它.我可以编写一个函数来手动将对象转换为JSON字符串,但是因为.Net可以使用<System.Web.Services.WebMethod()>
和<System.Web.Script.Services.ScriptMethod()>
属性动态地执行它所以必须有一个我缺少的内置方法.
PS:使用Asp.Net 2.0和VB.Net - 我把它放在标签中,但我认为人们错过了它.
asp.net ×2
c# ×2
.net-2.0 ×1
ajax ×1
algorithm ×1
angularjs ×1
apache-flex ×1
benchmarking ×1
compilation ×1
flexbuilder ×1
generics ×1
iis ×1
javascript ×1
jquery ×1
json ×1
linq ×1
listview ×1
macos ×1
math ×1
msbuild ×1
node-gyp ×1
npm ×1
scalability ×1
sharepoint ×1
socket.io ×1
svg ×1
svn ×1
tortoisesvn ×1
urlrewriter ×1
vb.net ×1