How to use DataPager control with Data List View in c#


HTML : (.aspx)
<!--Listview with pagger-->
                <asp:ListView runat="server" ID="ListView1" GroupItemCount="3" OnPreRender="ListView1_PreRender1">
                        <table cellpadding="2" runat="server" id="tblProducts" style="height: 320px;">
                            <tr align="left" runat="server" id="groupPlaceholder">
                        <asp:DataPager runat="server" ID="dpMyDatePager" PageSize="9">
                                <asp:NumericPagerField ButtonCount="2" PreviousPageText="<--" NextPageText="-->" />
                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowFirstPageButton="True" />
                        <tr runat="server" id="productRow" style="height: 80px">
                            <td runat="server" id="itemPlaceholder">
                        <td id="Td1" valign="top" width="279px" align="left" runat="server">
                            <div style="height: 350px; width: 100%; overflow-y: auto; overflow-x: hidden; margin-left:39px;">
                                <table class="mtbl">
                                        <td class="rTd">
                                                <img src="<%#Eval("Images")%>" style="width:196px;height:196px;" />
                                    <asp:Label ID="Label1" runat="server" Text='<%#Eval("Title")%>'></asp:Label>
                                <div id="details" class="details">
                                    <asp:Label ID="Label2" runat="server" Text='<%#Eval("Description")%>'></asp:Label>
C# code: (.aspx.cs)
    protected void ListView1_PreRender1(object sender, EventArgs e)
    private void loadgalary()
        DataTable dt = ClassGallery.FetchGallery();
        if (dt != null && dt.Rows.Count > 0)
            ListView1.DataSource = dt;


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

Popular posts from this blog

mvc jquery save

jquery save & fetch