2012-02-17 24 views
0

因此,我在VB中創建了此ListView用戶控件,並指定了我的數據源。我使用的佈局是「單行」佈局,分頁已啓用。但是,結果恰好是該行的10列(10個窗口)。我想知道如何讓默認列爲5?我檢查了這些屬性,似乎沒有這樣的屬性來控制該行開始的列數。如何在VB中爲「單行」佈局指定ListView的列數

感謝

編輯:參考

<asp:ListView ID="ListView1" runat="server" DataSourceID="RssDataSource1"> 
     <ItemTemplate> 
      <td runat="server" style="background-color:#DCDCDC;color: #000000;"> 
       title: 
       <asp:Label ID="titleLabel" runat="server" Text='<%# Eval("title") %>' /> 
       <br /> 
       link: 
       <asp:Label ID="linkLabel" runat="server" Text='<%# Eval("link") %>' /> 
       <br /> 
       description: 
       <asp:Label ID="descriptionLabel" runat="server" 
        Text='<%# Eval("description") %>' /> 
       <br /> 
       pubDate: 
       <asp:Label ID="pubDateLabel" runat="server" Text='<%# Eval("pubDate") %>' /> 
       <br /> 
       category: 
       <asp:Label ID="categoryLabel" runat="server" Text='<%# Eval("category") %>' /> 
       <br /> 
      </td> 
     </ItemTemplate> 
     <AlternatingItemTemplate> 
      <td runat="server" style="background-color:#FFF8DC;"> 
       title: 
       <asp:Label ID="titleLabel" runat="server" Text='<%# Eval("title") %>' /> 
       <br /> 
       link: 
       <asp:Label ID="linkLabel" runat="server" Text='<%# Eval("link") %>' /> 
       <br /> 
       description: 
       <asp:Label ID="descriptionLabel" runat="server" 
        Text='<%# Eval("description") %>' /> 
       <br /> 
       pubDate: 
       <asp:Label ID="pubDateLabel" runat="server" Text='<%# Eval("pubDate") %>' /> 
       <br /> 
       category: 
       <asp:Label ID="categoryLabel" runat="server" Text='<%# Eval("category") %>' /> 
       <br /> 
      </td> 
     </AlternatingItemTemplate> 
     <EmptyDataTemplate> 
      <table style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;"> 
       <tr> 
        <td> 
         No data was returned.</td> 
       </tr> 
      </table> 
     </EmptyDataTemplate> 
     <InsertItemTemplate> 
      <td runat="server" style=""> 
       title: 
       <asp:TextBox ID="titleTextBox" runat="server" Text='<%# Bind("title") %>' /> 
       <br /> 
       link: 
       <asp:TextBox ID="linkTextBox" runat="server" Text='<%# Bind("link") %>' /> 
       <br /> 
       description: 
       <asp:TextBox ID="descriptionTextBox" runat="server" 
        Text='<%# Bind("description") %>' /> 
       <br /> 
       pubDate: 
       <asp:TextBox ID="pubDateTextBox" runat="server" Text='<%# Bind("pubDate") %>' /> 
       <br /> 
       category: 
       <asp:TextBox ID="categoryTextBox" runat="server" 
        Text='<%# Bind("category") %>' /> 
       <br /> 
       <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
        Text="Insert" /> 
       <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
        Text="Clear" /> 
      </td> 
     </InsertItemTemplate> 
     <LayoutTemplate> 
      <table runat="server" border="1" 
       style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;"> 
       <tr ID="itemPlaceholderContainer" runat="server"> 
        <td ID="itemPlaceholder" runat="server"> 
        </td> 
       </tr> 
      </table> 
      <div style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;"> 
       <asp:DataPager ID="DataPager1" runat="server"> 
        <Fields> 
         <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
          ShowNextPageButton="False" ShowPreviousPageButton="False" /> 
         <asp:NumericPagerField /> 
         <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
          ShowNextPageButton="False" ShowPreviousPageButton="False" /> 
        </Fields> 
       </asp:DataPager> 
      </div> 
     </LayoutTemplate> 
     <EditItemTemplate> 
      <td runat="server" style="background-color:#008A8C;color: #FFFFFF;"> 
       title: 
       <asp:TextBox ID="titleTextBox" runat="server" Text='<%# Bind("title") %>' /> 
       <br /> 
       link: 
       <asp:TextBox ID="linkTextBox" runat="server" Text='<%# Bind("link") %>' /> 
       <br /> 
       description: 
       <asp:TextBox ID="descriptionTextBox" runat="server" 
        Text='<%# Bind("description") %>' /> 
       <br /> 
       pubDate: 
       <asp:TextBox ID="pubDateTextBox" runat="server" Text='<%# Bind("pubDate") %>' /> 
       <br /> 
       category: 
       <asp:TextBox ID="categoryTextBox" runat="server" 
        Text='<%# Bind("category") %>' /> 
       <br /> 
       <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
        Text="Update" /> 
       <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
        Text="Cancel" /> 
      </td> 
     </EditItemTemplate> 
     <SelectedItemTemplate> 
      <td runat="server" 
       style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;"> 
       title: 
       <asp:Label ID="titleLabel" runat="server" Text='<%# Eval("title") %>' /> 
       <br /> 
       link: 
       <asp:Label ID="linkLabel" runat="server" Text='<%# Eval("link") %>' /> 
       <br /> 
       description: 
       <asp:Label ID="descriptionLabel" runat="server" 
        Text='<%# Eval("description") %>' /> 
       <br /> 
       pubDate: 
       <asp:Label ID="pubDateLabel" runat="server" Text='<%# Eval("pubDate") %>' /> 
       <br /> 
       category: 
       <asp:Label ID="categoryLabel" runat="server" Text='<%# Eval("category") %>' /> 
       <br /> 
      </td> 
     </SelectedItemTemplate> 
    </asp:ListView> 
+0

從數據源中返回什麼?你有可能收到10個值嗎?在這種情況下,如果您只需要5列然後新建一行,則可以在代碼隱藏中執行此操作。 – 2012-02-17 17:41:19

+0

馬騰,實際上有19條記錄。我實際上想保留單行,如果用戶想要看到超出前5條記錄,他們可以按下下一個按鈕(在ListView配置中啓用)來滑動並查看其餘數據記錄。 – eastboundr 2012-02-17 17:50:36

回答

0

我發現的要顯示可以在尋呼機控制被指定的記錄的默認數量:

ASP:DataPager的ID = 「DataPager1」 RUNAT = 「服務器」 每頁= 「5」

結合GroupItemCount屬性,問題就解決了。無論如何,感謝所有人的幫助。

0

代碼,你可以發佈您的代碼?您是想按第5列排序,還是先顯示第5列?

數據源是什麼類型?

無論如何,過濾將在您的代碼後面。

試一下:http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.columns.aspx

(你總是可以包括所有的列和隱藏只是你不想過多的那些: Does anyone know of a way of hiding a column in an asp.net listview?

希望有所幫助。

+0

嗨rjcup3,我已經添加了代碼,正如你所看到的,我只是直接從工具箱拖放「ListView」控件。並指定源爲「RssDataSource1」,它實際上是一個日曆的RSS。所以我想只有5個窗口(列)顯示前5天的事件。然後,如果用戶想要查看日期,他們可以按Next查看將來的事件。所以是的,我一次只能看到5個。但默認情況下,ListView會給我10列。 – eastboundr 2012-02-17 17:47:25

+0

如果您仍希望數據源在下一次單擊時顯示下一個5,隱藏/取消隱藏可能是您的最佳選擇。當他們點擊下一步時,隱藏第一個5,顯示第二個集合。 – 2012-02-17 17:50:10

+0

rjcup3,感謝您的快速響應。實際上有19條記錄。它顯示了開頭的前10個記錄。由於我啓用了分頁功能。當我點擊下一頁(或第2頁)時,它會給我下面的9條記錄。所以我實際上仍然想使用分頁,但是每頁有10條記錄,我想每次只有5條記錄。由於它是日曆的RSS源,因此總記錄數可能會有所不同。所以我無法指定要用硬代碼隱藏多少條記錄...對於混淆抱歉。 – eastboundr 2012-02-17 17:59:24

相關問題