eastboundr
eastboundr

Reputation: 1877

How to specify the number of columns for ListView for "single row" layout in VB

So I created this ListView user control in VB, and specified my data source. The layout I used is "single row" layout and the paging is enabled. However, the result is exactly 10 columns (10 windows) for the row. I'm wondering how could I make the default column to be 5? I checked the properties and there seems to be no such property that controls how many columns to start with for the row.

Thanks

Edit: code for reference

<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>

Upvotes: 0

Views: 3259

Answers (2)

eastboundr
eastboundr

Reputation: 1877

I found out that the default number of records to be shown can be specified in the pager control:

asp:DataPager ID="DataPager1" runat="server" PageSize="5"

combined with GroupItemCount property, the problem is solved. Thanks all for the help anyways.

Upvotes: 1

RJ Cuthbertson
RJ Cuthbertson

Reputation: 1518

Can you post your code? Are you trying to sort by Column 5, or display Column 5 first?

What type is the data source?

Regardless, the filtering will be in your code behind.

Try here: http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.columns.aspx

(You could always include all columns and hide just the ones you don't want too: Does anyone know of a way of hiding a column in an asp.net listview? )

Hope that helps.

Upvotes: 0

Related Questions