GridView 在回发期间丢失数据 [英] GridView loses data during postback
问题描述
我有一个包含 gridview 的 aspx.Page.只有当没有发生回发并且 enableviewstate = true(页面也是)时,gridview 才会在代码后面绑定到数据源.在回发期间,绑定到 gridview 的数据将丢失.可能是什么原因.请问是否需要代码.
I have an aspx.Page containing a gridview. The gridview is bound in code behind to a datasource only when no postback takes place and has enableviewstate = true (The page too). During a postback, the data bound to the gridview are lost. What could be the reason. Please ask if code is needed.
推荐答案
解决了,问题是我用gridview在页面的masterpage的Page_Load事件中做了一个Page.Databind(),所以绑定了gridview每个没有数据的回发.感谢大家的努力.
Solved it, problem was I made a Page.Databind() in the Page_Load event of the masterpage of the page with the gridview, so it bound the gridview during each postback without data. Thanks for all efforts.
这篇关于GridView 在回发期间丢失数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!