页面加载时,使用 listview 和 datapager 导航到 listviewitem 所属的特定页面?

发布于 2024-09-27 02:32:47 字数 237 浏览 1 评论 0原文

我在会话中从 ListView 中选择了 DataKey。
当我返回到包含 listview 的 aspx 页面时,我可以将选择设置回来。
但是,当列表视图中的选定项目属于其他页面(不是第一个列表视图页面)时,我还需要将选定的列表视图页面设置为我的项目所属的页面。

我使用列表视图和数据分页器(带有模板分页)

我如何找到要选择的项目存在于哪个页面?

我可以搜索datakey值的页面然后激活它吗?

I have the selected DataKey in session from the ListView.
I am able to set the selection back when I comeback to this aspx page containing listview.
But when the selected item in the listview belongs to some other page (not the first listview page) then I need to also set the selected listview page to the one, where my item belongs.

I use a listview and a datapager (with template paging)

How can I find, in which page my item to be selected exists?

Can I search for the datakey value's page and then activate it?

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

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

发布评论

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

评论(1

陪你搞怪i 2024-10-04 02:32:47

我可以应用的最简单的解决方案是在会话中保存页面索引。
protected void ListView_PagePropertiesChanging(对象发送者,PagePropertiesChangingEventArgs e)
{ CurrentPageSessionVariable = (e.StartRowIndex / e.maximumRows);
}

现在正在页面加载...
dataPager1.SetPageProperties(CurrentPageSessionVariable * dataPager1.PageSize, dataPager1.MaximumRows, true);

这将确保当我们返回此页面时,数据分页器收到信号以加载指定页面并显示所选项目(这是单独的代码)。

Well the simplest solution I could apply was to also save the pageindex on session.
protected void ListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{ CurrentPageSessionVariable = (e.StartRowIndex / e.maximumRows);
}

Now on pageload...
dataPager1.SetPageProperties(CurrentPageSessionVariable * dataPager1.PageSize, dataPager1.MaximumRows, true);

This will ensure that when we comeback to this page, the datapager is signaled to load the specified page and show the selected item(which is separate code).

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