Click here to Skip to main content
14,385,103 members
   

ASP.NET

 
AnswerRe: what is major difference between blazor server app and asp.net mvc razor app? Pin
Mycroft Holmes11-Nov-19 21:20
MemberMycroft Holmes11-Nov-19 21:20 
GeneralRe: what is major difference between blazor server app and asp.net mvc razor app? Pin
Nitin Sawant11-Nov-19 23:04
MemberNitin Sawant11-Nov-19 23:04 
GeneralRe: what is major difference between blazor server app and asp.net mvc razor app? Pin
jkirkerx13-Nov-19 10:56
Memberjkirkerx13-Nov-19 10:56 
Questiongridview with dynamic dropdownlist control null exception Pin
Anand Solomon11-Nov-19 5:41
MemberAnand Solomon11-Nov-19 5:41 
Questionvideo calling in asp.net Pin
Member 146439065-Nov-19 19:37
MemberMember 146439065-Nov-19 19:37 
AnswerRe: video calling in asp.net Pin
F-ES Sitecore6-Nov-19 2:04
MemberF-ES Sitecore6-Nov-19 2:04 
AnswerRe: video calling in asp.net Pin
Blikkies6-Nov-19 2:28
MemberBlikkies6-Nov-19 2:28 
Questioni want show page numbers in bottom of the page like <1 2 3 4 5.......10 11 12> but it shows <1 2 3 4 5 6 to total> Pin
Member 134445211-Nov-19 21:17
MemberMember 134445211-Nov-19 21:17 
This my aspx code
<table align="center">
        <tr valign="top">
            <td>
                <asp:DataList ID="gv1" runat="server" RepeatColumns="1" RepeatDirection="Horizontal">
                    <HeaderTemplate>
                        Our Tutors List</HeaderTemplate>
                    <ItemTemplate>
                        <table width="600px" border="2" align="center">
                            <tr align="center">
                                <td width="100%" valign="top" style="font-size: 15px">
                            <span class="newstext_1">Name:</span> <%#DataBinder.Eval(Container.DataItem, "FirstName")%>  <%#DataBinder.Eval(Container.DataItem, "LastName")%>
                            <%--<span class="newstext_1">Mobile:</span>        <%#DataBinder.Eval(Container.DataItem, "MobileNo")%>    
                               <span class="newstext_1">Email Id:</span>     <%#DataBinder.Eval(Container.DataItem, "EmailId")%>    --%>
                                </td>
                            </tr>
                            <tr>
                                <td>
                               <span class="newstext_1">Qualification:</span>    <%#DataBinder.Eval(Container.DataItem, "Qualification")%>            
                                  <span class="newstext_1">Experience:</span>  <%#DataBinder.Eval(Container.DataItem, "Experience")%>
                                     
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <span class="newstext_1">Subjects:</span>
                                    <%#DataBinder.Eval(Container.DataItem, "Subjects")%>            
                                    <%--<span class="newstext_1">Created Date:</span> <%#DataBinder.Eval(Container.DataItem, "CreatedDate")%>--%>
                                </td>
                            </tr>
                             <tr>
                                <td>
                                    <span class="newstext_1">Locations:</span>
                                    <%#DataBinder.Eval(Container.DataItem, "Location")%> 
                                   
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <span class="newstext_1">Description:</span>
                                    <%#DataBinder.Eval(Container.DataItem, "Description")%>
                                </td>
                            </tr>
                           
                                                   
                        </table><br /><br />
                    </ItemTemplate>
                    <FooterTemplate>
                    </FooterTemplate>
                </asp:DataList>
                
                <table width="100%" border="0">
        <tr bgcolor=""  align="center">

            <td>
                <asp:LinkButton ID="lnkbtnPrevious" runat="server" Text="<" OnClick="lnkbtnPrevious_Click"></asp:LinkButton>
            </td>
            <td>
                <asp:DataList ID="dlPaging" runat="server" RepeatDirection="Horizontal" OnItemDataBound="dlPaging_ItemDataBound"
                    OnItemCommand="dlPaging_ItemCommand" OnSelectedIndexChanged="dlPaging_SelectedIndexChanged"
                    UseAccessibleHeader="True">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkbtnPaging" runat="server" CommandArgument='<%#Eval("PageIndex")%>'
                            CommandName="lnkbtnPaging" Text='<%#Eval("PageText")%>'></asp:LinkButton>  
                    </ItemTemplate>
                </asp:DataList>
            </td>
            <td>
                <asp:LinkButton ID="lnkbtnNext" runat="server" Text=">" OnClick="lnkbtnNext_Click"></asp:LinkButton>
            </td>
        </tr>
    </table>
            </td>
            
        </tr>
    </table>




<aspx.cs code="">
using System;
using System.Data;
using System.Web.UI.WebControls;

public partial class MathsTutors : System.Web.UI.Page
{
    PagedDataSource pds = new PagedDataSource();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }
    private void BindData()
    {
        ClsTutorDetails tutor = new ClsTutorDetails();
        DataTable dt = tutor.GetAllTutors("Active");



        pds.DataSource = dt.DefaultView;
        pds.AllowPaging = true;
        pds.PageSize = 12;
        pds.CurrentPageIndex = CurrentPage;
        lnkbtnNext.Enabled = !pds.IsLastPage;
        lnkbtnPrevious.Enabled = !pds.IsFirstPage;

        gv1.DataSource = pds;
        gv1.DataBind();

        if (dt.Rows.Count <= 12)
        {
            dlPaging.Visible = false;
            lnkbtnNext.Visible = false;
            lnkbtnPrevious.Visible = false;
        }
        else
        {
            dlPaging.Visible = true;
            lnkbtnNext.Visible = true;
            lnkbtnPrevious.Visible = true;
        }

        doPaging();



    }

    

    #region

    private void doPaging()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("PageIndex");
        dt.Columns.Add("PageText");
        for (int i = 0; i < pds.PageCount; i++)
        {
            DataRow dr = dt.NewRow();
            dr[0] = i;
            dr[1] = i + 1;
            dt.Rows.Add(dr);
        }

        dlPaging.DataSource = dt;
        dlPaging.DataBind();
    }

    public int CurrentPage
    {

        get
        {
            if (this.ViewState["CurrentPage"] == null)
                return 0;
            else
                return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
        }

        set
        {
            this.ViewState["CurrentPage"] = value;
        }

    }
    protected void lnkbtnPrevious_Click(object sender, EventArgs e)
    {
        CurrentPage -= 1;
        BindData();
    }

    protected void lnkbtnNext_Click(object sender, EventArgs e)
    {
        CurrentPage += 1;
        BindData();
    }


    protected void dlPaging_SelectedIndexChanged(object sender, EventArgs e)
    {
        CurrentPage = 0;
        BindData();

    }

    protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName.Equals("lnkbtnPaging"))
        {
            CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
            BindData();
        }
    }

    protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging");
        if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString())
        {
            lnkbtnPage.Enabled = false;
            lnkbtnPage.Font.Bold = true;

        }
    }
    #endregion
}

AnswerRe: i want show page numbers in bottom of the page like <1 2 3 4 5.......10 11 12> but it shows <1 2 3 4 5 6 to total> Pin
Richard Deeming3-Nov-19 23:33
MemberRichard Deeming3-Nov-19 23:33 
QuestionASP.Net Core Identity Pin
Mycroft Holmes28-Oct-19 14:11
MemberMycroft Holmes28-Oct-19 14:11 
AnswerRe: ASP.Net Core Identity Pin
jkirkerx30-Oct-19 14:10
Memberjkirkerx30-Oct-19 14:10 
GeneralRe: ASP.Net Core Identity Pin
Mycroft Holmes31-Oct-19 12:13
MemberMycroft Holmes31-Oct-19 12:13 
GeneralRe: ASP.Net Core Identity Pin
jkirkerx1-Nov-19 13:23
Memberjkirkerx1-Nov-19 13:23 
QuestionImporting Rows Into a List Pin
ibrahimayhans28-Oct-19 1:37
Memberibrahimayhans28-Oct-19 1:37 
QuestionASP maker 2018 Pin
Member 1292025327-Oct-19 12:23
MemberMember 1292025327-Oct-19 12:23 
AnswerRe: ASP maker 2018 Pin
Richard MacCutchan27-Oct-19 23:19
MemberRichard MacCutchan27-Oct-19 23:19 
QuestionDraw Shape in Canvas Pin
John_Ryder26-Oct-19 2:58
MemberJohn_Ryder26-Oct-19 2:58 
AnswerRe: Draw Shape in Canvas Pin
Afzaal Ahmad Zeeshan26-Oct-19 10:19
MemberAfzaal Ahmad Zeeshan26-Oct-19 10:19 
GeneralRe: Draw Shape in Canvas Pin
John_Ryder29-Oct-19 20:49
MemberJohn_Ryder29-Oct-19 20:49 
AnswerRe: Draw Shape in Canvas Pin
jkirkerx28-Oct-19 13:53
Memberjkirkerx28-Oct-19 13:53 
QuestionHow do i make my detailsviewmodel work Pin
Stefaneus22-Oct-19 7:31
MemberStefaneus22-Oct-19 7:31 
AnswerRe: How do i make my detailsviewmodel work Pin
jkirkerx23-Oct-19 11:54
Memberjkirkerx23-Oct-19 11:54 
QuestionHow do i make a bootstrap carousel work with Asp.net core Razor Pin
Stefaneus21-Oct-19 15:49
MemberStefaneus21-Oct-19 15:49 
AnswerRe: How do i make a bootstrap carousel work with Asp.net core Razor Pin
Richard Deeming22-Oct-19 2:00
MemberRichard Deeming22-Oct-19 2:00 
GeneralRe: How do i make a bootstrap carousel work with Asp.net core Razor Pin
Stefaneus22-Oct-19 6:02
MemberStefaneus22-Oct-19 6:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.