Quick Asp.Net ListView Template

Posted by OmegaMan at June 7, 2009

Category: ASP.Net, Controls

Tags: ,

I find that I seem to make the same Asp.Net ListView and internal table html code over and over. The below code contains that table where each row of data corresponds will be bound to each row of data in a database. Here is that template with blank values which will need to be filled in:

<asp:ListView ID="lvXXXXX"              
              DataKeyNames=""              
              runat="server"              
              ItemPlaceholderID="PlaceHolder1">
    <LayoutTemplate>    
        <table class="">        
            <thead>            
                <tr>                
                    <th>Header 1</th>            
                </tr>        
            </thead>        
            <tbody>
                <asp:PlaceHolder runat="server" ID="PlaceHolder1" />
            </tbody>    
        </table>
    </LayoutTemplate>
    <ItemTemplate>    
        <tr>        
            <td><asp:Label ID="lblYYYY"                
                     runat="server"                
                     Text='<%# Eval("") %>'/>        
            </td>    
        </tr>
    </ItemTemplate>
</asp:ListView>
Share

2 Comments

  1. Check out my other article which discusses how to use a CheckBox and retrieve data row IDs from the Listbox on the CheckBoxe’s OnChange event! Click the link to the left of this text.

    Reply
  2. asp.net, c#,javascript says

    asp.net, c#,javascript…

    […]Quick Asp.Net ListView Template « OmegaMan's Musings[…]…

    Reply

Leave a comment

(required)
(required) (will not be published)

This site uses Akismet to reduce spam. Learn how your comment data is processed.