---
title: "ListView Control in ASP.Net"  
description: "The ASP.NET ListView control enables you to bind to data items that are returned from a data source and display them. You can display data in pages. Y"  
author: "Pushpendra Singh"  
published: 2010-11-08  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/193/listview-control-in-asp-dot-net  
category: "ado.net"  
tags: ["ado.net"]  
reading_time: 2 minutes  

---

# ListView Control in ASP.Net

The ASP.NET [ListView](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.aspx) control enables you to bind to data items that are returned from a data source and display them. You can display data in pages. You can display items individually, or you can group them.\

The [ListView](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.aspx) control displays data in a format that you define by using templates and styles. It is useful for data in any repeating structure, similar to the [DataList](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.aspx) and [Repeater](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.aspx) controls. However, unlike those controls, with the [ListView](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.aspx) control you can enable users to edit, insert, and delete data.

##### BindData in ListView:

```
<asp:ListView ID="ListView1" runat="server" ItemPlaceholderID="itemPlaceholder">         <LayoutTemplate>            <table border="0" cellpadding="1">                <tr style="background-color:  #E5E5FE">                    <th align="left">       <asp:LinkButton ID="lnkId" runat="server">Id</asp:LinkButton>                    </th>                    <th align="left">        <asp:LinkButton ID="lnkName" runat="server">Name</asp:LinkButton>                    </th>                    <th align="left">        <asp:LinkButton ID="lnkType" runat="server">Type</asp:LinkButton>                    </th>                    <th>                    </th>                </tr>                <tr id="itemPlaceholder" runat="server">                </tr>            </table>         </LayoutTemplate>         <ItemTemplate>            <tr>                <td>   <asp:Label runat="server" ID="lblId"><%#Eval("id") %></asp:Label>                </td>                <td>   <asp:Label runat="server" ID="lblName"><%#Eval("pass")%></asp:Label>                </td>                <td>      <asp:Label runat="server" ID="lblType"><%#Eval("name") %></asp:Label>                </td>                <td>                </td>            </tr>         </ItemTemplate>         <AlternatingItemTemplate>            <tr style="background-color:  #EFEFEF">                <td>       <asp:Label runat="server" ID="lblId"><%#Eval("id") %></asp:Label>                </td>                <td>        <asp:Label runat="server" ID="lblName"><%#Eval("pass") %></asp:Label>                </td>                <td>        <asp:Label runat="server" ID="lblType"><%#Eval("name") %></asp:Label>                </td>                <td>                </td>            </tr>         </AlternatingItemTemplate>    </asp:ListView>protected void Page_Load(object sender, EventArgs e)    {         BindData();    }     public void BindData()    {         ListView1.DataSource = Class1.execute_spfill_grid("insert_reg");         ListView1.DataBind();      }
```

![ListView Control in ASP.Net](https://www.mindstick.com/mindstickarticle/c6cd1b7d-d710-4bc4-9724-4cf63dbb2c86/images/d80e99a2-1aa0-43aa-9d8d-15dbd8add555.png)

![ListView Control in ASP.Net](https://www.mindstick.com/mindstickarticle/c6cd1b7d-d710-4bc4-9724-4cf63dbb2c86/images/440dbce0-a07c-473e-ab48-f6171435c021.png)

##### Paging in ListView:

##### Use Data Pager control for paging in ListView

```
<asp:DataPager runat="server" ID="EmployeesDataPager" PageSize="1"          PagedControlID="ListView1" onprerender="EmployeesDataPager_PreRender">  <Fields>   <asp:NumericPagerField /></Fields></asp:DataPager>
```

##### Write below code in DataPager PreRender event

```
protected void EmployeesDataPager_PreRender(object sender,  EventArgs e)    {         ListView1.DataSource = Class1.execute_spfill_grid("insert_reg");         ListView1.DataBind();      }
```

\

![ListView Control in ASP.Net](https://www.mindstick.com/mindstickarticle/c6cd1b7d-d710-4bc4-9724-4cf63dbb2c86/images/f508c6ea-016a-4ffb-843e-5883f0cf57b8.png)

![ListView Control in ASP.Net](https://www.mindstick.com/mindstickarticle/c6cd1b7d-d710-4bc4-9724-4cf63dbb2c86/images/d7d2ecc7-4d21-4df4-97d5-f215a6593ea7.png)

\

---

Original Source: https://www.mindstick.com/articles/193/listview-control-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
