ListView 与 DataPager 问题 VB.Net / ASP.NET
我几天来一直在寻找这个问题,到目前为止我已经尝试了很多流行的方法,绝对没有效果,我的列表视图在我重新绑定后就消失了。我将用于索引功能的 List(Of KeyValuePair(Of String, Integer)) 绑定到 ListView。当我第一次绑定它时,它工作得很好,它显示了 DataPager 所需限制中的所有键和值对,但是当我转向分页器时,列表视图消失了。
以下是调用 ListView 上的 PagePropertiesChanging 时发生的情况。
Me.DataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, False)
userInterface.DataPagerReBind(ListView1)
而实际的 ListView
<asp:ListView ID="ListView1" runat="server" EnableTheming="True" OnPagePropertiesChanging="ListView1_PagePropertiesChanging">
<LayoutTemplate>
<table cellpadding="2" width="640px" border="1" ID="tbl1" runat="server">
<tr id="Tr2" runat="server" style="background-color: #98FB98">
<th id="Th1" runat="server">Test point name</th>
<th id="Th2" runat="server">Number of failed Test points</th>
</tr>
<tr runat="server" id="itemPlaceHolder" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr1" runat="server">
<td>
<asp:Label ID="VendorIDLabel" runat="server" Text='<%# Eval("key") %>' />
</td>
<td>
<asp:Label ID="AccountNumberLabel" runat="server" Text='<%# Eval("value") %>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:DataPager ID="DataPager1" runat="server" PageSize="10" PagedControlID="ListView1" >
<Fields>
<asp:NextPreviousPagerField
ButtonType="Link"
ShowFirstPageButton="True"
ShowNextPageButton="False"
ShowPreviousPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
和 userInterface.DataPagerRebind 只是将 listview 重新绑定到原始列表。 有人可以帮忙吗?我真的在这里迷路了,这困扰了我很长时间,当我使用寻呼机时,列表视图就消失了。 谢谢。
userInterface.DataPagerReBind 的定义:
Sub DataPagerReBind(ByRef listView1 As ListView)
listView1.DataSource = TestList
listView1.DataBind()
End Sub
I've been hunting down this problem for days, so far I have tried many popular methods, absolutely nothing, my listview just dissapears after I rebind it. I am binding a List(Of KeyValuePair(Of String, Integer)), for the indexing functionality, to ListView. When I first bind it, it works nicely, it shows all the key, and value pairs in the required limits of DataPager, but when I turn to pager, the listview dissapears.
Heres what happens when PagePropertiesChanging on ListView is called.
Me.DataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, False)
userInterface.DataPagerReBind(ListView1)
And the actual ListView
<asp:ListView ID="ListView1" runat="server" EnableTheming="True" OnPagePropertiesChanging="ListView1_PagePropertiesChanging">
<LayoutTemplate>
<table cellpadding="2" width="640px" border="1" ID="tbl1" runat="server">
<tr id="Tr2" runat="server" style="background-color: #98FB98">
<th id="Th1" runat="server">Test point name</th>
<th id="Th2" runat="server">Number of failed Test points</th>
</tr>
<tr runat="server" id="itemPlaceHolder" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr1" runat="server">
<td>
<asp:Label ID="VendorIDLabel" runat="server" Text='<%# Eval("key") %>' />
</td>
<td>
<asp:Label ID="AccountNumberLabel" runat="server" Text='<%# Eval("value") %>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:DataPager ID="DataPager1" runat="server" PageSize="10" PagedControlID="ListView1" >
<Fields>
<asp:NextPreviousPagerField
ButtonType="Link"
ShowFirstPageButton="True"
ShowNextPageButton="False"
ShowPreviousPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
And userInterface.DataPagerRebind just rebinds the listview to the original list.
Can anyone help? I've realy gone lost here, this has troubling me for soo long, the listview just dissapears when I use the pager.
Thank you.
Definition for userInterface.DataPagerReBind:
Sub DataPagerReBind(ByRef listView1 As ListView)
listView1.DataSource = TestList
listView1.DataBind()
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)