当分拣ASP.net的GridView数据源的空 [英] ASP.net gridview datasource null when sorting
问题描述
在这里,我们再次在排序的下一个问题。
Here we are again with the next problem in sorting.
这是一个后续问题这个问题
我现在已经做了一个类型包含我需要的数据。 然而,当我尝试获取数据返回null GridView控件,这意味着我无法排序任何不存在摆在首位...
I have now made a type to contain the data I need. however, when I try to fetch the data FROM the gridview it returns null, which means I can't sort anything that is not there in the first place...
任何想法,为什么返回null ...
any ideas why this returns null ...
IEnumerable<JointServerData> data = gvServers.DataSource;
var sorted = data;
switch (p)
{
case "domain":
sorted = data.OrderBy(o => o.DomainName);
break;
default:
break;
}
gvServers.DataSource = sorted;
gvServers.DataBind();
以上就是我试图做...
above is what I'm trying to do ...
推荐答案
在没有看到所有的code我不得不认为这是一个回发的问题。网站的本质上是无状态的,你需要通过任一页面的缓存请求之间的信息或每次检索数据。
Without seeing all your code I'd have to assume that this is a PostBack issue. Website's are intrinsically stateless and you need to resolve this by either caching information between page requests or retrieving the data each time.
这篇关于当分拣ASP.net的GridView数据源的空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!