|
|
Comments and Discussions
|
|
 |

|
I'm just compile and I'm getthis message.
Parser Error Message: Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 27: <compilation debug="true">
Line 28: <assemblies>
Line 29: <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 30: </assemblies>
Line 31: </compilation>
|
|
|
|

|
How to use this if I bind DataList with SqlDataSource or ObjectDataSource? I don't have code-behind bindong of datalist control.
<asp:sqldatasource id="SqlDataSource1" runat="server" xmlns:asp="#unknown">
ConnectionString="<%$ ConnectionStrings:mYConnectionString %>"
SelectCommand="SELECT * FROM [table]"></asp:sqldatasource>
<asp:datalist id="DataList1" runat="server" datakeyfield="id" xmlns:asp="#unknown">
DataSourceID="SqlDataSource1">
<itemtemplate>
id:
<asp:label id="id" runat="server" text="<%# Eval("id") %>" />
<br />
kat:
<asp:label id="katLabel" runat="server" text="<%# Eval("kat") %>" />
</itemtemplate>
</asp:datalist>
<uc1:pagercontrol id="PagerControl1" runat="server" itemsperpage="10" mode="Hyperlink" xmlns:uc1="#unknown" />
This doesn't work.
|
|
|
|

|
Hi Daniel,
I would like to use your control but encounter the following problem converting it to VWD2008 Express edition.
I had to place the DataControlAdapter.cs, PageChangeEventArgs.cs, UserControlBase.cs in the App_Code folder. Doing this it is not possible anymore to instantiate from the PagerControl in the DataControlAdapter, because it sits outside of the App_Code folder.
public class DataControlAdapter
{
GridView gridView;
int pageIndex;
int itemCount;
int itemsPerPage;
---> PagerControl pagerControl;
public PagerControl PagerControl
{
get
{
return pagerControl;
}
set
Do you know how I can solve this problem?
Many thanks.
|
|
|
|

|
Hi Martin,
Are you using Service Pack 1? I ask because Visual Web Developer 2008 Express Edition SP1 now has support for Web Application Projects. If you use a Web Application as opposed to a Website, you shouldn’t have too many problems. Otherwise you will have to fiddle a bit to get it working.
Cheers,
Daniel
|
|
|
|

|
Hi Daniel,
Thanks for your fast reply. I will upgrade to SP1 and try again.
Best regards
|
|
|
|

|
Daniel,
This control looks great and I'd like to use it in one of my projects. However, I'm having trouble getting the control to work in a Visual Studio 2008/Framework 3.5 web site. When attempting to build the web site I receive:
Could not load type 'Orpius.Web.Controls.PagerControl'. PagerControl.ascx Line 1
I'm not sure what's causing this as your demo project runs ok when converted to VS 2008. Can you offer some advice on this?
You ought to be able to replicate the behaviour using the following steps:
1. From within VS 2008, create a new web site. I used a file system site but I doubt it matters.
2. Copy the Controls folder from your demo site to the root of the new site.
3. Copy the App_GlobalResources folder from your demo site to the root of the new site.
4. Attempt to build the site. Error should appear.
Thanks in advance.
Dave
|
|
|
|

|
Hi Dave,
I followed your steps and found that I was able to recreate the website by first converting it to 2008, then copying the converted files to a newly created ASP .NET Web application. Make sure that all the designer files are included in the project.
Daniel
|
|
|
|

|
Hi, The control looks awesome and I would love to use it however I'm doing something wrong or there is a problem with my configuration. I am using Visual Web Developer Express 2005 (VWD) and building a wep app with a gridview. I have placed all files as per the instructions and dragged the control file to the design surface of the form. It shows the PagerControl tags with the red squiggle error, the error message is the subject line of this msg. Also, a new line is shown at the top of the page source listing: <%@ Register Src="Controls/PagerControl/PagerControl.ascx" TagName="PagerControl" TagPrefix="uc1" %> ................................ VWD error after website build states: Could not load type 'Orpius.Web.Controls.PagerControl'. File: PagerControl.ascx Line: 1 ............................. Please let me know if you can help. Thanks, Dawg modified on Tuesday, March 25, 2008 10:02 PM
|
|
|
|

|
Hi Dawg,
So the class Orpius.Web.Controls.PagerControl isn’t being resolved. Is the namespace of the PagerControl.ascx.cs equal to Orpius.Web.Controls? Is the Build Action of the file set to 'Compile'?
|
|
|
|

|
I am getting this error
Could not load type orpius.web.controls.pagercontrol when I try to complile the demosite. I actually don't know why I am getting this error and not sure how I can get rid of it. It is on the Inherits line of the Page directive.
<![CDATA[<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PagerControl.ascx.cs" Inherits="Orpius.Web.Controls.PagerControl" %>]]>
Seems to me the path is fine.
Is the demosite in a state it can be ran when loaded into V5?
|
|
|
|

|
The demo site is buildable and runnable. I just downloaded and tested it on another PC using VS 2005 SP1.
Is the build action property of the PagerControl.ascx.cs file set to Compile?
I would try downloading it again.
Let me know how you go.
Daniel
|
|
|
|

|
This is very nice. Thank you for sharing
|
|
|
|

|
Thanks merlin981. I'm glad you like it.
|
|
|
|

|
Hi,
I am trying to add the control to a VS2005 web site by manually copying it as described.
However when compiling the solution I get some errors related to <%=Resources.Site.Controls_Pager_PreviousLink%> not being accessable.
Please advice.
|
|
|
|

|
Hi Dumitru,
thanks for telling me about this. Copy the Site.resx file to your App_GlobalResources directory. I didn't mention this in the steps to setup the control, so I'll do an update soon.
Daniel
|
|
|
|

|
Thank you Daniel.
It is ok now. Very nice control.
|
|
|
|

|
Hi Daniel - thanks for the article and pager component. I have two comments:
1. It would be helpful to have a version without the ASP.NET AJAX stuff.
2. I'm interested in how would you use this, with a bound Grid View (ASP.NET 2.0)?
For number 1, taking out the AJAX stuff seems fairly simple - replace web.config with a version without AJAX, remove the reference to the "extensions" dll, remove the "scriptmanager" component in the master template, and some more changes. I only ask because we don't yet have ASP.NET AJAX instaled on our production servers.
For number 2, I work with Grid Views but find the in-built paging barely practical. Your component is 10x better (and a lot better looking)
Cheers,
Thomas Williams
http://dotnetjunkies.com/WebLog/thomasswilliams/
|
|
|
|

|
Hi Thomas, Thanks for your kind comments. 1. That will do the trick. I haven't included anything custom in the web.config. You may also want to delete LinkButtonModeWithAjax.aspx 2. That's a good point. I will include that in the next update. To use a GridView set the AllowPaging property of the GridView instance to true. Set the GridView's PagerSettings Visible property to false. In the PagerControl1_OnPageChanging handler set the PageIndex of the GridView to the PageChangeEventArgs PageIndex property, and then call DataBind() on the GridView. I have just finished a GridView demo. For now I will post the source here for you. Create a new WebForm GridView.aspx. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GridView.aspx.cs" Inherits="Orpius.Web.GridView" MasterPageFile="~/Site.Master" %> <%@ Register Src="Controls/PagerControl/PagerControl.ascx" TagName="PagerControl" TagPrefix="Orpius" %> <asp:Content ID="Content_Main" runat="server" ContentPlaceHolderID="ContentPlaceHolder_Content"> <div style="margin-bottom:20px"> <asp:GridView ID="GridView_DummyData" runat="server" AllowPaging="True"> <PagerSettings Visible="False" /> </asp:GridView> </div> <div style="margin-bottom:20px"> <Orpius:PagerControl id="PagerControl1" runat="server" OnPageChanging="PagerControl1_OnPageChanging"> </Orpius:PagerControl> </div> </asp:Content>
GridView.aspx.cs looks like this: using System; using System.Collections.Generic; using Orpius.Web.Controls; namespace Orpius.Web { public partial class GridView : System.Web.UI.Page { static int itemCount = 50; List<DummyDataItem> dummyData = new List<DummyDataItem>(itemCount); protected void Page_Load(object sender, EventArgs e) { LoadDummyData(); GridView_DummyData.DataSource = dummyData; if (!IsPostBack) { GridView_DummyData.DataBind(); PagerControl1.ItemsPerPage = GridView_DummyData.PageSize; PagerControl1.ItemCount = dummyData.Count; } } void LoadDummyData() { dummyData.Clear(); for (int i = 1; i <= itemCount; i++) { DummyDataItem item = new DummyDataItem("Item " + i); dummyData.Add(item); } } protected void PagerControl1_OnPageChanging(object sender, PageChangeEventArgs e) { GridView_DummyData.PageIndex = e.PageIndex; GridView_DummyData.DataBind(); } } } Daniel Vaughan
|
|
|
|
|

|
Hi Daniel,
if you don't mind I have a small sugestion to make.
I have the following case:
I need to use your pager with a GridView that has an ObjectDataSource with custom paging enabled.
This means that I can set the PagerControl1.ItemCount property, only, after the ObjectDataSource executed the SelectCountMethod="GetRecordCount" method.
So, the total number of records in the database is available only after the "Selected" event of the ObjectDataSource is fired.
The issue is that, this event is fired after the Page_Load event of the page (and also of the PagerControl).
Checking your source code I noticed that the UpdatePager(PageIndex) method is called in Page_Load, at which time the ItemCount propery is 0.
By calling the UpdatePager(PageIndex) in OnPreRender, the Pager's properies can be set up at later stages than Page_Load.
For instance:
protected void objDs_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
// --- We might have the SelectedCount executed so we process the number of total records.
try
{
int nCount = System.Convert.ToInt32(e.ReturnValue);
PagerControl1.ItemsPerPage = GridView.PageSize;
PagerControl1.ItemCount = nCount;
}
catch (Exception ex)
{
// do nothing as nothing bad happend
}
}
Another small issue: the Panel_Pager.Visible = ItemCount > ItemsPerPage need to be called also in OnPrerender.
One more time: great job with this control.
Regards.
-- modified at 8:45 Wednesday 21st November, 2007
|
|
|
|

|
Thanks Dumitru.
I'll include this in the next update, and I really appreciate your input.
Cheers,
Daniel
|
|
|
|

|
Hi Daniel,
First of all, thank you very much for creating a pager that is worth (well worth) including in a product. The standard pager simply is not good enough for a professional solution in my opinion.
On my project I was introduced your pager after reading a bit about it. It was very easy to insert into my existing GridViews, however I had to make some modifications to make it work correctly (special cases). The first thing I had to do was the same a Dumitru, since I had some things I wanted to set up before the rendering, so I moved some code (actually all of your Page_Load(object sender, EventArgs e) content) to the OnPreRender(EventArgs e) method. This solved some of the problems.
One last problem remained: I am using the pager for a GridView (actually several) where you can edit/update/delete the rows "inline" so to speak. Edit/update did not pose a problem, however Delete did in the extreme (last page) case.
Consider the following:
You have a GridView with a page size of 2, you have a total of 3 rows to display. You navigate to the second (and last) page and view 1 row. Here you click on Delete to delete the last row. Now the pager (naturally) was very confused since I was on a page which did not exist, and the calculation was just messed up big time. It displayed "showing 3 to 4 ..." even though only 2 rows were present (and NOT shown).
To deal with that situation I had to make a few modifications.
1. Move the Page_Load(object sender, EventArgs e) content to the OnPreRender(EventArgs e) method
2. Introduce a variable, moveBackOnePage which determines if the pager should jump back one page before rendering.
3. Always set the variable moveBackOnePage to false in the Page_Load(object sender, EventArgs e)
4. Create a new method, MoveBackOnePage() which sets the moveBackOnePage variable to true.
5. At the bottom of the OnPreRender(EventArgs e) right before UpdatePager(PageIndex); I check if the moveBackOnePage variable is set, and if so I decrement the PageIndex by one. (if (moveBackOnePage) { PageIndex -= 1; }
That was all I had to change in your pager code. However there was still one task left to finish the job. Everytime I had to (re)display the page, I now had to check if I was currently on the last page (and NOT the first - they can be the same) and if I deleted the last entry on the page. To implement this, I simply extended on Dimitrus thoughts and ended up with the following code in my page codebehing file:
protected void ObjectDataSource1_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
// We might have the SelectedCount executed so we process the total number of records.
try
{
int nCount = System.Convert.ToInt32(e.ReturnValue);
PagerControl1.ItemsPerPage = TheGridView.PageSize;
PagerControl1.ItemCount = nCount;
// Figure out which page is the last
int lastPage = PagerControl1.ItemCount / PagerControl1.ItemsPerPage;
// Find the number of rows displayed on the last page
int rowsOnLastPage = PagerControl1.ItemCount % PagerControl1.ItemsPerPage;
// If we are on the last+ page (and not the first! - if only one page is available)
if (PagerControl1.PageIndex > 0 && PagerControl1.PageIndex >= lastPage)
{
// If we are on a page larger than the last OR we are on the last page but there are no rows
if (PagerControl1.PageIndex > lastPage || rowsOnLastPage == 0)
{
// Move the pager back one page to display the "real" last page.
PagerControl1.MoveBackOnePage();
}
}
}
catch (Exception)
{
// do nothing as nothing bad happened. This is due to 2 calls to this method
// where only one of them performs the right task, and the other throws an exception
// which we don't care about
}
}
As the code shows I determine in which situations it is appropriate to move the pager back one page before rendering it. As this is called after the Page_Load(object sender, EventArgs e) method of the pager but before the OnPreRender(EventArgs e) method, we can safely do it. The approach above may not be the prettiest solution, but it solved my problem. I hope it can inspire you to think about the problem, and maybe integrate a solution into your pager if possible. I think it requires some interaction between the codebehind of the page holding the pager, and the pager itself, but maybe you can figure out something neat .
By the way, I modified the control to work with the Theme my project is using, and doing so was very easy thanks to the CSS classes you defined, and the simple background image. Great job!
Thanks again for a very nice control!
Regards,
Nicolai
|
|
|
|

|
Hi Nicolai,
Thank you for taking the time to write me a detailed message about your exploits with the control.
The control should obviously be able to cope with the scenario you describe. I haven’t used it with a GridView yet, so I didn’t spot that. Sounds like it required a bit of hacking to bend it to your will eh.
As you suggest, I will try to come up with an integrated solution to the problem in an update (which is now very overdue!).
Thanks again Nicolai.
Kind regards,
Daniel
|
|
|
|

|
I have updated the control. Thank you very much for your feedback.
|
|
|
|

|
thanks alote
Nicolai
i need your code if you can
becouse i tried but not work
Please send me source code
to
"
On my project I was introduced your pager after reading a bit about it. It was very easy to insert into my existing GridViews, however I had to make some modifications to make it work correctly (special cases). The first thing I had to do was the same a Dumitru, since I had some things I wanted to set up before the rendering.
"
i have same case
Please....
thanks alot
Ahmad
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Yet another list pager, but this one can use LinkButtons or simple Hyperlinks, provides scrolling within an ASP.NET AJAX UpdatePanel, and behaves similarly to the paging found on Amazon.com.
| Type | Article |
| Licence | BSD |
| First Posted | 21 Oct 2007 |
| Views | 42,684 |
| Downloads | 213 |
| Bookmarked | 58 times |
|
|