Solved

Repeater And Dropdown List

Posted on 2013-05-31
1
501 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

862 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

24 Experts available now in Live!

Get 1:1 Help Now