Solved

Repeater And Dropdown List

Posted on 2013-05-31
1
500 Views
Last Modified: 2013-06-04
Dear Gurus,
I want to put paging datas to a dropdown list.
But I can't.
This is my sexy code behind:
        private void LoadData()
        { 
            SqlDataAdapter da = new SqlDataAdapter("Select Top 50 Title From tbl_Title Order By TID Desc", myFunction.GetConnections.NormalSqlConnect());
            DataTable dt = new DataTable();
            da.Fill(dt);
            PagedDataSource pgitems = new PagedDataSource();
            DataView dv = new DataView(dt);
            pgitems.DataSource = dv;
            pgitems.AllowPaging = true;
            pgitems.PageSize = 10;
            pgitems.CurrentPageIndex = PageNumber;
            if (pgitems.PageCount > 1)
            {
                rptPages.Visible = true;
                ArrayList pages = new ArrayList();
                for (int i = 0; i < pgitems.PageCount; i++)
                    pages.Add((i + 1).ToString());
                rptPages.DataSource = pages;
                rptPages.DataBind();
            }
            else
                rptPages.Visible = false;
            rptItems.DataSource = pgitems;
            rptItems.DataBind();
        }
        void rptPages_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            PageNumber = Convert.ToInt32(e.CommandArgument) - 1;
            LoadData();
        }

        private int PageNumber
        {
            get
            {
                if (ViewState["PageNumber"] != null)
                    return Convert.ToInt32(ViewState["PageNumber"]);
                else
                    return 0;
            }
            set
            {
                ViewState["PageNumber"] = value;
            }
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            rptPages.ItemCommand +=
               new RepeaterCommandEventHandler(rptPages_ItemCommand);
        }

Open in new window

This is front page:
      <asp:Repeater ID="rptPages" Runat="server">
      <HeaderTemplate>
         <b>Page:</b>
      </HeaderTemplate>
      <ItemTemplate>
         <asp:LinkButton ID="btnPage"
                         CommandName="Page"
                         CommandArgument="<%#
                         Container.DataItem %>"
                         CssClass="text"
                         Runat="server"><%# Container.DataItem %>
                         </asp:LinkButton>&nbsp;
      </ItemTemplate>
      <FooterTemplate>
      </FooterTemplate>
      </asp:Repeater>
      <asp:Repeater ID="rptItems" runat="server">
      <HeaderTemplate>
      </HeaderTemplate>
      <ItemTemplate>
          <li><a href="<%#myFunction.clearLink(Eval("Title").ToString()) %>"><span class="small3parmakicon"><%#Eval("Title") %></a></span></li>
      </ItemTemplate>
      <FooterTemplate>
      </FooterTemplate>
      </asp:Repeater>

Open in new window


Could you give an example?
Thanks.
0
Comment
Question by:fancyfanta
1 Comment
 
LVL 12

Accepted Solution

by:
Jitendra Patil earned 500 total points
ID: 39212544
try this from the link given below.
Custom paging in Repeater control in asp.net(C#, VB)

hope this helps.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now