Implement Paging in Repeater control in update panel using C# and VB.Net in ASP.Net

Last Reply 3 months ago By NoorAhmed2

Posted 3 months ago

Hello Dear Sirs:

Please, I have a question about inserting datapager in the updatepanel. Here I have TESTIMONIALS that I automatically call from the database. What is the mechanism to automatically insert datapager so that all TESTIMONIALS do not appear at once, so many are on the page?

For example, in each page we put only nine TESTIMONIALS.

Page link here:

Http://cglobalc.com/Pages/EN/Testimonials.aspx

Here is the code:

 Asp.net Page :

<asp:Content ID="Content5" ContentPlaceHolderID="ContentPlaceHolderBodyMain" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div class="row">
        <div class="container-fluid">
            <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
                <ContentTemplate>
                    <div class="container" style="margin: 20px auto;">
                        <div style="float: left; text-align: left; direction: ltr; margin-right: 20px;">
                            <div class="lblEn" style="color: #000; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
                                font-size: 15px;">
                                Search</div>
                            <asp:TextBox ID="TextBoxNo" runat="server" CssClass="txtEn" Style="color: brown;
                                border-color: #C8C9CB; height: 30px; float: left; margin-right: 25px;"></asp:TextBox>
                            <div style="float: left; text-align: left; direction: ltr; margin-right: 20px;">
                                <asp:DropDownList ID="DropDownListCountry" runat="server" CssClass="txtEn" Width="140px"
                                    AutoPostBack="true" Style="color: #000; border-style: none;">
                                </asp:DropDownList>
                            </div>
                            <div style="float: left; text-align: left; direction: ltr; margin-right: 20px;">
                                <asp:DropDownList ID="DropDownListYears" runat="server" CssClass="txtEn" Width="140px"
                                    AutoPostBack="true" Style="color: #000; border-style: none;">
                                </asp:DropDownList>
                            </div>
                            <div style="float: left; text-align: left; direction: ltr; margin-right: 20px;">
                                <asp:DropDownList ID="DropDownListCategory" runat="server" CssClass="txtEn" Width="140px"
                                    AutoPostBack="true" Style="color: #000; border-style: none;">
                                </asp:DropDownList>
                            </div>
                            <div style="float: left; text-align: left; direction: ltr; margin-right: 20px;">
                                <asp:DropDownList ID="DropDownListSubCategory" runat="server" CssClass="txtEn" Width="150px"
                                    AutoPostBack="true" Style="color: #000; border-style: none;">
                                </asp:DropDownList>
                            </div>
                            <div style="float: left; text-align: left; direction: ltr; margin: -10px 0px 0px 35px;">
                                <asp:Button ID="btnGo" runat="server" Text="Find" Style="border-style: none; color: #FFF;
                                    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px;
                                    background-color: #C91216; width: 75px; border-radius: 4px; margin-top: 10px;
                                    height: 30px;"></asp:Button>
                            </div>
                        </div>
                    </div>
                    <br />
                    <div class=" col-md-12" style="margin-left: auto; margin-right: auto; display: block;">
                        <asp:Repeater ID="RepeaterTestFilter" runat="server">
                            <ItemTemplate>
                                <div class=" col-md-4">
                                    <div class="testimonial">
                                        <div class="content">
                                            <div class="testimonial-pic">
                                                <%# Eval("TestCatLogo")%>
                                            </div>
                                            <div style="text-align: center; margin-left: auto; margin-right: auto; display: table;
                                                margin-top: -70px; color: white; font-size: 18px; margin-bottom: 20px;">
                                                <%# Eval("SubCatName")%>
                                                <span style="margin-right: 3px;">
                                                    <asp:Label ID="Label1" runat="server"><%# ProcessMyDataItem(Eval("CourseENName"))%></asp:Label></span>
                                                <span style="margin-right: 3px;">
                                                    <asp:Label ID="Label2" runat="server"><%# ProcessMyDataItem2(Eval("BookENName"))%></asp:Label></span>
                                                <span style="margin-right: 3px;">
                                                    <asp:Label ID="Label3" runat="server"><%# ProcessMyDataItem3(Eval("TrainingENName"))%></asp:Label></span>
                                                <span style="margin-right: 3px;">
                                                    <asp:Label ID="Label4" runat="server"><%# ProcessMyDataItem4(Eval("ProgramENName"))%></asp:Label></span>
                                            </div>
                                        </div>
                                        <br />
                                        <br />
                                        <div class="testimonial-prof">
                                            <div class="style-2 scrollbar">
                                                <p style="font-family: 'Droid Arabic Kufi', serif; direction: rtl;">
                                                    <%# Eval("EditorArea")%></p>
                                                <br />
                                            </div>
                                        </div>
                                        <br />
                                        <div style="float: left; font-family: 'Droid Arabic Kufi', serif; direction: rtl;">
                                            <h3 class="testimonial-title">
                                                <cite>
                                                    <%# Eval("MembName")%></cite></h3>
                                        </div>
                                    </div>
                                </div>
                                </div>
                            </ItemTemplate>
                        </asp:Repeater>
                        <%--<div class="pager">
                            Page:
                            <asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListViewMainFilter"
                                PageSize="5">
                                <Fields>
                                    <asp:NumericPagerField />
                                </Fields>
                            </asp:DataPager>
                            <br />
                            <br />
                        </div>--%>
                    </div>
                    </div>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnGo" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="DropDownListCountry" EventName="SelectedIndexChanged" />
                    <asp:AsyncPostBackTrigger ControlID="DropDownListCountry" EventName="TextChanged" />
                    <asp:AsyncPostBackTrigger ControlID="DropDownListCategory" EventName="SelectedIndexChanged" />
                    <asp:AsyncPostBackTrigger ControlID="DropDownListCategory" EventName="TextChanged" />
                    <asp:AsyncPostBackTrigger ControlID="DropDownListYears" EventName="SelectedIndexChanged" />
                    <asp:AsyncPostBackTrigger ControlID="DropDownListYears" EventName="TextChanged" />
                </Triggers>
            </asp:UpdatePanel>
        </div>
    </div>
</asp:Content>

 

VB Code :
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.ComponentModel
Imports System.Web.Services.Description
Imports System.Net.Mail
Imports System.Web.Mail
Imports System.Collections
Imports System.Drawing
Imports System.IO
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Net.Mail.MailMessage

Partial Class Pages_EN_Testimonials
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        PobulateCountry()
        PobulateCategory()
        PobulateSubCategory()
        PobulateYears()
        getdata()
    End Sub
    Public Sub getdata()
        Dim objTest As New DB_Testimonials

        objTest.ProMembName = TextBoxNo.Text
        objTest.ProCountryID = DropDownListCountry.SelectedValue
        objTest.ProTestCatID = DropDownListCategory.SelectedValue
        objTest.ProTestSubCatID = DropDownListSubCategory.SelectedValue
        objTest.ProYearsID = DropDownListYears.SelectedValue

        Dim dt As DataTable = objTest.Find()
        RepeaterTestFilter.DataSource = dt
        RepeaterTestFilter.DataBind()

    End Sub

    Public Sub PobulateCountry()
        If Not IsPostBack Then
            Dim objCountry As New DB_Country
            Dim dt As DataTable = objCountry.Find()

            Dim dr As DataRow = dt.NewRow()
            dr("CountryID") = 0
            dr("CountryName") = "Country"

            dt.Rows.InsertAt(dr, 0)

            DropDownListCountry.DataValueField = "CountryID"
            DropDownListCountry.DataTextField = "CountryName"

            DropDownListCountry.DataSource = dt
            DropDownListCountry.DataBind()
        End If

    End Sub

    Public Sub PobulateCategory()
        If Not IsPostBack Then
            Dim objCategory As New DB_TestCategory
            Dim dt As DataTable = objCategory.Find()

            Dim dr As DataRow = dt.NewRow()
            dr("TestCatID") = 0
            dr("TestCatName") = "Category"

            dt.Rows.InsertAt(dr, 0)

            DropDownListCategory.DataValueField = "TestCatID"
            DropDownListCategory.DataTextField = "TestCatName"

            DropDownListCategory.DataSource = dt
            DropDownListCategory.DataBind()
        End If

    End Sub
    Public Sub PobulateSubCategory()
        If Not IsPostBack Then
            Dim objsubCategory As New DB_TestSubCategory
            Dim dt As DataTable = objsubCategory.FindTestSubCategory()

            Dim dr As DataRow = dt.NewRow()
            dr("TestSubCatID") = 0
            dr("SubCatName") = "Type Of Category"

            dt.Rows.InsertAt(dr, 0)

            DropDownListSubCategory.DataValueField = "TestSubCatID"
            DropDownListSubCategory.DataTextField = "SubCatName"

            DropDownListSubCategory.DataSource = dt
            DropDownListSubCategory.DataBind()
        End If

    End Sub

    Public Sub PobulateYears()
        If Not IsPostBack Then
            Dim objyears As New DB_Years
            Dim dt As DataTable = objyears.Find()

            Dim dr As DataRow = dt.NewRow()
            dr("yearsID") = 0
            dr("yearsName") = "Years"

            dt.Rows.InsertAt(dr, 0)

            DropDownListYears.DataValueField = "yearsID"
            DropDownListYears.DataTextField = "yearsName"

            DropDownListYears.DataSource = dt
            DropDownListYears.DataBind()
        End If

    End Sub

    Protected Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click
        getdata()
    End Sub
    Public Function ProcessMyDataItem(myValue As Object) As String

        If myValue Is DBNull.Value Then

            Return ""


        End If

        Return myValue.ToString()

    End Function

    Public Function ProcessMyDataItem2(myValue As Object) As String
        If myValue Is DBNull.Value Then
            Return ""
        End If

        Return myValue.ToString()
    End Function

    Public Function ProcessMyDataItem3(myValue As Object) As String
        If myValue Is DBNull.Value Then
            Return ""
        End If

        Return myValue.ToString()
    End Function

    Public Function ProcessMyDataItem4(myValue As Object) As String
        If myValue Is DBNull.Value Then
            Return ""
        End If

        Return myValue.ToString()
    End Function
End Class

Thank You ,

NoorAhmed

Posted 3 months ago Modified on 3 months ago

Hi NoorAhmed2,

Please refer the below article.

Implement Paging in Repeater control in ASP.Net

 


I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html