从 GridView 获取数据集?

发布于 2024-11-02 11:01:18 字数 143 浏览 1 评论 0原文

我如何从我填充的网格视图中获取数据集?

我试过这个:

Dim importedDS As DataSet = gwResults.DataSource

但它一直都是空白的。还有别的办法吗?

how can i get the dataset from a gridview i have populated?

i tried this:

Dim importedDS As DataSet = gwResults.DataSource

but it's coming out blank all the time. is there another way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初心 2024-11-09 11:01:18

寻找另一种方法来存储/检索/缓存数据集或您需要的特定值。

当您首次检索数据集并将其分配给网格时,您将能够在页面请求的其余部分访问它。一旦页面请求结束,HTTP 上下文和页面以及任何关联的对象都会被清除,它们将被设置为垃圾收集并销毁。 (无论如何,就我们而言)

在下一篇文章中,网格将从表单中重新加载它的值(以及视图状态中的一些属性),但不是整个数据集,因为它从未存储在表单中/查看状态。将数据集保持在视图状态将是极其低效的。这就是为什么 DataSource 属性在后续回发时将为空白的原因。

Find another way to store/retrieve/cache the dataset, or the specific values you need from it.

When you first retrieve a dataset and assign it to a Grid, you will be able to access it for the remainder of the page request. As soon as the page request is over, the HTTP context and page and any associated objects are purged, they will be set for garbage collection and destroyed. (As far as we're concerned, anyway)

On the next post back, the grid will reload it's values from the form, (and some properties from view state), but not the whole dataset, since that was never stored in the form/view state. Keeping a dataset in view state would be a incredibly inefficient. This is why the DataSource property will be blank on subsequent post backs.

随梦而飞# 2024-11-09 11:01:18

正如另一个人提到的,一旦请求结束 - 对象就不再在范围内。
您如何将网格绑定到数据集?您是否正在执行 if (!IsPostBack)?

As another person mentioned, once the request is over - the objects aren't in scope anymore.
How are you binding the Grid to the DataSet and are you doing an if (!IsPostBack)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文