如何以编程方式迭代 GridView 的页面

发布于 2024-09-29 06:27:52 字数 1611 浏览 3 评论 0原文

我创建了一个墙板应用程序来显示我的 ICT 部门的未完成的支持呼叫。我已将许多 gridview 绑定到执行存储过程的 sqldatasources。这是通过 asp.net ajax 控件自动完成的,并且每 30 秒部分刷新页面/数据。

目前,当gridview中的记录数超过9时,gridview会自动分页,并在右下角显示页数。然后,帮助台可以通过 VNC 连接到控制屏幕的框,并手动单击以查看下一页上的内容。

我所追求的是一种以编程方式(使用 c# 代码隐藏文件)在 10/15 秒左右后更改当前显示页面的方法,显然如果这在 gridview 的范围内是可能的。我使用 javascript(在 jquery 中失败)在 div 内滚动 gridview,但这并没有按预期工作。

谁能指出我正确的例子吗?我找不到其他人通过快速谷歌查询此功能。任何有关如何解决此问题的帮助/建议将不胜感激!

Gridview代码:

<asp:GridView ID="GridView1" ShowHeader="False" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
GridLines="None" CellPadding="2" Font-Size="35pt" AllowPaging="True" PageSize="9">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID">
<ItemStyle Width="15%" />
</asp:BoundField>
<asp:BoundField DataField="ASSIGNEES" HeaderText="ASSIGNEES" SortExpression="ASSIGNEES">
<ItemStyle Width="32%" Wrap="false"/>
</asp:BoundField>
<asp:BoundField DataField="title" HeaderText="title" SortExpression="title">
<ItemStyle Width="53%"  Wrap="false"/>
</asp:BoundField>
</Columns>
</asp:GridView>

SqlDataSource代码:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FPConnectionString %>" SelectCommand="HDMonitoringOutstandingToday" SelectCommandType="StoredProcedure"></asp:SqlDataSource>

墙板打印屏幕:

墙板示例.JPG

I've created a wallboard application to display outstanding support calls for my ICT department. I've bound a number of gridviews to sqldatasources which execute a stored procedure. This is automated via asp.net ajax controls and partially refreshes the page/data every 30 seconds.

At the moment, when the number of records in the gridview goes over 9, the gridview automatically pages and shows the number of pages in the bottom right hand corner. The helpdesk can then VNC to the box which controls the screen and manually click to see what's on the next page.

What I am after is a way to programmatically (using the c# code-behind file) changing the current displayed page after 10/15 seconds or so, obviously if this is possible in the scope of the gridview. I trailed using javascript (and failed at jquery) of scrolling the gridview within a div, however this didn't work as expected.

Can anyone point me in the right example? I can't find anyone else querying this functionality via a quick Google. Any help/advice of how to fix this issue would be greatly appreciated!!

Gridview Code:

<asp:GridView ID="GridView1" ShowHeader="False" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
GridLines="None" CellPadding="2" Font-Size="35pt" AllowPaging="True" PageSize="9">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID">
<ItemStyle Width="15%" />
</asp:BoundField>
<asp:BoundField DataField="ASSIGNEES" HeaderText="ASSIGNEES" SortExpression="ASSIGNEES">
<ItemStyle Width="32%" Wrap="false"/>
</asp:BoundField>
<asp:BoundField DataField="title" HeaderText="title" SortExpression="title">
<ItemStyle Width="53%"  Wrap="false"/>
</asp:BoundField>
</Columns>
</asp:GridView>

SqlDataSource Code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FPConnectionString %>" SelectCommand="HDMonitoringOutstandingToday" SelectCommandType="StoredProcedure"></asp:SqlDataSource>

Printscreen of wallboard:

wallboard example.JPG

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

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

发布评论

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

评论(2

柏拉图鍀咏恒 2024-10-06 06:27:52

您可以在计时器中尝试类似的操作。

if(GridView1.PageIndex == GridView1.PageCount)
{
   GridView1.PageIndex = 0;
}
else
{
   GridView.PageIndex = GridView.PageIndex + 1;
}

我不记得您是否需要在 PageIndex 中添加 1。

但无论如何,您需要使用的属性是 PageIndex 和 PageCount。

You can try something like this in a timer.

if(GridView1.PageIndex == GridView1.PageCount)
{
   GridView1.PageIndex = 0;
}
else
{
   GridView.PageIndex = GridView.PageIndex + 1;
}

I cant remember if you would need to add one to the PageIndex or not.

But anyway, the properties you need to work with are PageIndex and PageCount.

近箐 2024-10-06 06:27:52
GridView.PageIndex 

您可以通过设置 PageIndex 来更改页面,具体操作方式取决于您在此处查看的一些示例:http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pageindex.aspx

GridView.PageIndex 

You can change pages by setting the PageIndex, how you do it is up to you see here for some examples: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pageindex.aspx

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