LISTVIEW for the first time in a web form RRS feed

  • Question

  • User1816379506 posted

    I have been attempting to create a listview for the first time in a Web Form.  I have read examples but no matter what I think they mean I can not get a listview with two (2) colums so I can have something to start with.  Could someone please send me the code to create a listview with two columns.  Column one DATE 10 bytes, colomn two DESCRIPTION 20 bytes.  From there I should be able to continue.  I would like to use my VB code to select certain entries from my database the display these entries in a listview.  I would like to have my VB code select the entries ( not all entries).

    Thursday, December 4, 2014 4:22 PM


All replies

  • User2103319870 posted

    You can add a table with two column to itemtemplate property of listview like given below

    <asp:ListView ID="ListView1" runat="server" GroupPlaceholderID="groupPlaceHolder1" DataSourceID="SqlDataSource1"
                <table border="1" width="50%">
                        <td style="width: 50%">
                            <asp:Label ID="LabelFN" runat="server" CssClass="Label" Text='<%#Eval("AddressID") %>' /><br />
                        <td style="width: 50%">
                            <asp:Label ID="LabelDOB" runat="server" CssClass="Label" Text='<%#Eval("AddressLine1") %>' /><br />
                    <asp:PlaceHolder runat="server" ID="groupPlaceHolder1"></asp:PlaceHolder>
                    <asp:PlaceHolder runat="server" ID="itemPlaceHolder1"></asp:PlaceHolder>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorks2008R2ConnectionString %>"
            DataSourceMode="DataReader" SelectCommand="SELECT top 10 [AddressID], [AddressLine1], [AddressLine2] FROM Person.[Address]">

    Thursday, December 4, 2014 5:16 PM
  • User1816379506 posted

    A2H, I have attempted to make the example that you sent work but was unable to.   This is my first listview in the Web appl area so I guess what I need to start with is a working set that I do not have to change so I can see how it work and I will copy and make changes as needed.  I guess what I am saying the example does not work as is.  I need a starter if anyone have one.

    Monday, December 8, 2014 4:04 PM
  • User1918509225 posted

    Hi decal,

    For your issue,i  suggest that you can try the tutorial which instruct how to create listview :


    Best Regards,

    Kevin Shen.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 11, 2014 12:47 AM