几天来我一直在寻找这个问题,到目前为止我已经尝试了很多流行的方法,绝对没有,我的列表视图在我重新绑定后就消失了。我将用于索引功能的 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 只是将列表视图重新绑定到原始列表。任何人都可以帮忙吗?我真的迷路了,这让我困扰了很久,当我使用寻呼机时,列表视图就消失了。谢谢你。
userInterface.DataPagerReBind 的定义:
Sub DataPagerReBind(ByRef listView1 As ListView)
listView1.DataSource = TestList
listView1.DataBind()
End Sub