I have two paging controls on the same page. It's quite wierd to me that both don't work in different place. Let me explain...
1 2 >>
Take the above as an example... 1 is a label, 2 and >> is a linkbutton, which has the command argument set to 1. 2 is created dymanically (depending of the number of next pages there are)
If I click 2 on the paging control at the top, the event is captured, but the argument is empty.
If I click 2 on the paging control at the bottom, the event is not captured, and I can't test the argument.
On the second click, both controls work perfectly... Any idea y?
Best Regards, Kit Kai, MVP (SharePoint Portal Server)
The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral
Here is the code... very long...
#region
{
Literal oLiteral;
oLiteral =
oLiteral.Text = "Page ";
oLiteral.Text = " of ";
oLiteral.Text = " (";
oLiteral.Text = " items)";
}
#endregion
LinkButton oLinkButton;
oLinkButton =
oLinkButton.CausesValidation =
oLinkButton.CssClass =
oLinkButton.Command +=
LastPage = 0;
LastPage = Convert.ToInt32(System.Math.Floor(Convert.ToDouble(
LastPage++;
CurrentPage =
((LinkButton)
LinkButton oLinkButton = ((LinkButton)
oLinkButton.Visible =
oLinkButton.Text = (CurrentPage + 1).ToString();
oLinkButton.ToolTip = "Page " + (CurrentPage + 1).ToString();
oLinkButton.CommandArgument = (CurrentPage).ToString();
[Category("Appearance"), DefaultValue("")]
ViewState[Properties.PageItemCssClass] = String.Empty;
ViewState[Properties.PageItemCssClass] =
[Category("Information"), DefaultValue(0)]
ViewState[Properties.CurrentPage] = 0;
ViewState[Properties.CurrentPage] =
[Category("Appearance"), DefaultValue(5)]
ViewState[Properties.NoNextPage] = 5;
CreateNextLinkButtons();
ViewState[Properties.NoNextPage] =
[Category("Appearance"), DefaultValue(10)]
ViewState[Properties.PageSize] = 10;
ViewState[Properties.PageSize] =
UpdateUI();
[Category("Appearance"), DefaultValue(2)]
ViewState[Properties.NoPreviousPage] = 2;
CreatePreviousLinkButtons();
ViewState[Properties.NoPreviousPage] =
ViewState[Properties.TotalRecords] = (
ViewState[Properties.TotalRecords] =
Page.Trace.Write("Page Argument: " + (
icelava wrote:Custom paging controls? What does Trace have to "say"?
Icelava, go to the admin url for the event management system. Manage Events has enough info for paging to be used... Trace is enabled there...
icelava wrote:Error: Checksum mismatch while reading representation: Error: expected: 799369d16cd60689d86108bb5511aae5 Error: actual: f853814f2d9371d2896968eedfac7deb
I'm not sure about the INamingContainer part, have to check.
As for point 2 and 3, I remember that if you override createchildcontrol, you should not be overriding render method, because the default render method will render the control based on the controls collection property. If you override render method, you should not be overriding createchildcontrol... right?
icelava wrote:I do not know where you read such a ruling, but CreateChildControls() and Render() are not mutually exclusive devices. They achieve their own purposes in the scheme of building a control and outputting its final "visual" contents.
So how do I add html tags in between those controls that i add to the control collections?
********************
icelava wrote: What is the purpose of Page 0? I don't believe it is an array that is being dealt with here. So seeing "Page 0 of 2" on first appearance and subsequent loss of ability to return to that (first) page is confusing.
At first I made the page index start from 1, but later, I think datagrid's currentpageindex starts from 0 right? So I change it to start from 0, to standardise.
icelava wrote: The defaults for NoPreviousPage and NoNextPage are 2 and 5 respectively, which are created regardless of knowledge of actual number of items and page size, and then gets "corrected" later in PreRender()/UpdateUI() phase. Shouldn't the number of LinkButtons before/after be created as according tothe more reliable information?
NoPreviousPage and NoNextPage is used to determine how many previous pages you want to show and how many next pages you want to show. When the control first initialise, I create the linkbuttons in the control hierarchy first, just in case the code didn't assign a value to the property after initialisation. But if someone who might use the control sets one of the two property, I clear the control hierarchy, and recreate those controls based on the two property.
These two properties are independent of the number of items and page size, because if the number of items is less than the page size, i just hide them. It actually makes things simplier as I do not need to keep checking if the controls are created when the number of items or the currentpage changes, which is often when you add records or nagivate between records. The two properties and the page size should remain static after initialisation.