public knowledge blog_load(sender Virendra)

                                                                                                                          Nothing shocks me, I am a Software Engineer.

ASP.NET 4.0 : ListView Control Enhancements

Posted by Virendra Dugar on May 27, 2009

The ListView control, which was introduced in ASP.NET 3.5, has all the functionality of the GridView control while giving you complete control over the output. This control has been made easier to use in ASP.NET 4.0. The earlier version of the control required that you specify a layout template that contained a server control with a known ID. The following markup shows a typical example of how to use the ListView control in ASP.NET 3.5.

 <asp:ListView ID="ListView1" runat="server">
  <LayoutTemplate>
     <asp:PlaceHolder ID="ItemPlaceHolder" runat="server"></asp:PlaceHolder>
  </LayoutTemplate>
  <ItemTemplate>
     <% Eval("LastName")%>
  </ItemTemplate>
</asp:ListView>

In ASP.NET 4.0, the ListView control does not require a layout template. The markup shown in the previous example can be replaced with the following markup:

<asp:ListView ID="ListView1" runat="server">
  <ItemTemplate>
     <% Eval("LastName")%>
  </ItemTemplate>
</asp:ListView>
 
Enjoy…
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: