ListView 与 DataPager 问题 VB.Net / ASP.NET

发布于 2024-12-06 08:45:11 字数 2310 浏览 0 评论 0原文

我几天来一直在寻找这个问题,到目前为止我已经尝试了很多流行的方法,绝对没有效果,我的列表视图在我重新绑定后就消失了。我将用于索引功能的 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 技术交流群。

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

发布评论

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

评论(1

夏日浅笑〃 2024-12-13 08:45:11
 protected void DataPager1_PreRender(object sender, EventArgs e)
    {
       //Assign the updated datasource to your listview again
       //Bind the listview.

    }

这是 C# 代码,因此请尝试使用 vb.net 中的寻呼机预渲染事件

 protected void DataPager1_PreRender(object sender, EventArgs e)
    {
       //Assign the updated datasource to your listview again
       //Bind the listview.

    }

This is C# code so try to use the pager prerender event in vb.net

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