c# - Custom Paging Repeater Control next and previous events happen after databind -
To
I have inherited and paging functionality of a custom repeater control repeater, but when I click the next page button for the first time It does refresh the control, but if I do not change it then it changes the page completely after that click the page.
I know what that problem is, when I next button it does a postback, then after that the NextButton event is controlled, the data is bound to the repeater, and so on.
Is there any way I can change the order of page load events ?? Or is the event controlled after reloading ?? Repeater forced
I have included my custom repeater class bellow:
using System.Web.UI.WebControls; Using System.Web.UI; Using System.Data; Using System.Collections; Using the system; Namespace ASPresentation.Controls {[ToolboxData ( "& LT; CC: PagedRepeater runat = server & gt; & lt; / cc: PagedRepeater & gt;")] to get the public square PagedRepeater: Repeater {public int PageSize {; Set; } Public Entry Ongoing Page Index {get {return Convert.ToInt16 (Page session ["Project Index"]); } Set {Page.Session.Add ("ProjectIndex", value); }} Public PagedDataSource pagedData = New PagedDataSource (); Link button NextBtn = new link button (); Link button prevBtn = new link button (); Public Bull isLastPage {get {pagedData.IsLastPage; }} Public Balls Esfarst Page {get pagedData.IsFirstPage; }} Public override object data source ({return base.DataSource;} set {pagedData.DataSource = (IEnumerable) value;}} protected void NextButtonClick (object sender, EventArgs e) {if (! IsLastPage) {CurrentPageIndex ++;} } protected void PrevButtonClick (object sender, EventArgs e) {if (! IsFirstPage) {CurrentPageIndex--;}} protected override void OnInit (EventArgs e) {base.OnInit (e); NextBtn.Text = "Next"; PrevBtn. Text = "Back"; NextBtn.Click + = new Iventhandlr (NextButtonClick); PrevBtn.Click + = new Iventhaandlr (Preebbtnklik);} protected override void OnLoad (EventArgs e) {base.OnLoad (e); base.Controls.Add (Pre vBtn); base.Controls.Add (NextBtn);} render void override safety (HtmlTextWriter writer) {base.Render (writer);} public override void Databind () {pagedData.AllowPaging = true; PagedData.PageSize = PageSize; PagedData.CurrentPageIndex = CurrentPageIndex; Base.DataSource = pagedData; base.DataBind ();}}}
There are a couple issues that jump out on me here. One, why are you dynamically making the last / next button? Just put them in ASCX. If you prefer on the basis that your page index is first / last, show / hide them if you should make them dynamically, then in init ... Two, this way the session Do not store your page index in. What happens when you have two of these custom reporter on one page? Use viewstate key if necessary, control ID string of names, but I think Wustret does it automatically (?). Finally, is the databind triggering? What event handler? It should be said from this page which is hosting this control. If this is the case, you could be called Detabnd in response to these events that need to be exposed as events next / first clicks. How control is Microsoft that is guaranteed to manage paging work handle, such as Gridwu NextBtn.Click or PrevBtn.Click last postback event. You can handle internally as the next / previous internal, but if you're going to do it, you need to call the databank () in your code, so it's at the right time Ho.
Comments
Post a Comment