.net - Paged ObjectDataSource Results In PageSize -1?
Jun 11, 2010
I'm using a ListView with a Paged DataSource. When the ObjectDataSource tries to fetch data from the "GetData"-method, the parameter PageSize is set to -1, even though I have set the PageSize to 8 in the DataPager.
I have a model called 'BusinessPage' which can be associated with 1 or more 'BusinessPageCategories'. So I've got a 3rd table called 'BusinessPagesInCategories' that links these two.I am trying to get a paged recordset of BusinessPages, along with the total number of records (I may have 100 rows in total but only return 20 at a time, but I pass back an int containing that total number in addition to the 20 rows).The problem I have is that, since I implemented the Many-To-Many relationship, it was bringing back the same BusinessPage row x times (where x is the number of categories that BusinessPage is associated with). I only want a single instance of each business page to be returned. So I added the following to my NHibernate Criteria to give Distinct BusinessPage results..SetResultTransformer(CriteriaSpecification.DistinctRootEntity);
Whilst this works for me, in that I'm now correctly getting a single row per BusinessPage (and my Categories property within each BusinessPage contains the correct x categories that it's assigned to), my row count is not reflecting that 'distinct' count - instead, if I have just 1 BusinessPage record which is associated with 3 categories, the row count is 3!?!
public virtual int BusinessPageId { get; private set; } public virtual IList<BusinessPageCategory> Categories { get; set; } public virtual string BusinessName { get; set; }
Using a SubSonic (2.2) SqlQuery object, I am querying a view that contains distinct rows from another table. The results of the query, however, contain multiple rows for certain rows in the view. It appears to be because of a join on a temporary table in the query generated to achieve paging. How can I avoid this duplication of rows?
Bonus points: I have to use the view because SubSonic can't do .Paged() and .Distinct() at the same time. Why not?
I got a list of customers I thought I would list in a gridview or a repeater with customer html, it gone have paging. I'm gone have a checkbox for each customer in the list. Do you guys have any suggestions on how I should do to keep the checkbox value when I go to page 2-3-4 ect in the paging. I'm thinking a session to store the id of the checked customers. After I'm done setting the values they go to the database.
Do you got any other ideas then the session I'm thinking of?
I need to make a large Ebay-style list of listings (think of the page that comes up when you search for something in Ebay, with a photo, title, one-line description, price, that's paged, and sortable). My limited experience with DataGrids in the past always resulted in what felt like a sluggish page to me, but I'm not sure if it would have been faster if I had pieced it together with a data reader instead.So I'm wondering before I even get started, what is the fastest / most efficient way to retrieve and manage this data.Is it more efficient at runtime to use a DataGrid, or to write the paging and sorting in more manually and use a DataReader, or another way?Ebay manages to get thousands of listings to display very quickly, but they've obviously got a lot of manpower to squeeze every last bit of performance they can out of the site, and good high-powered servers.
I have a DataGrid that has event handlers bound to SortCommand and PageIndexChanged. How can I determine if those event handlers are about to be called, say on page_load? These events will fire just fine after page_load, but I'd like to know at page_load if they are to be fired.
in my webapplication i create a pdf document based on a pdf template which paegsize is Iso C6 (envelope ). The documet is returned to the client in the response output stream .
If i choose to open the document (and print it) , i have the printer pagesize automatically set to the a4 pagesize;
This cause a side effect : the text printed on the envelope is not in the right position because the printer pagesize is different (on a a4 paper the envelope is centered on the paper!!!).
Is it possible to insert information into the gridview's pager, like "Showing 10 of 55 items (You are on page 3)" and bind that information accordingly to the actual PageCount and PageSize properties?
I can only think of doing it outside the pager, even outside the GridView.
I need your help / guidence for doing custom paging in c#, through sqlserver. so that i can have data in dataset/datatable according to the pagesize given, not all the data in dataset. some code /url .......with full discrption if possible.
There is a gridview and I am binding some records to it. in my database there are 4 records but gridview always shows 3 records. Even I have given PageSize 10.
When (in what event) is the best time to set PageSize for the ListView's DataPager? I have tried every event on the ListView and either it does not work (i.e., reverts to the default 10) or I get a CRASH of some sort (mostly error 12002) - but that's a different story.
I'm using PrincipalContext, UserPrincipal and PrincipalSearcher to get the total number of objects in a particular OU. I know total is somewhere around 9,000. But what I get is 1,000. I've tried modifying the underlying searcher to set PageSize and SizeLimit, but same result. Here is the code:
I am extending the GridView control to include a custom pager for a custom paging scheme (only one page returned from the database at a time rather than all records). In my testing a discovered an issue - on my last page of data, the GridView's rows property always returns a collection of PageSize page, rather than the actual number of records on the page, with non-data fill records being empty rows.
For example, suppose I have 23 records in my database. Assuming a PageSize of 10, when I page to the last page of data the gridview it properly displays the last 3 recrods - but when I handle the GridView's CommandName="Select" event the GridView's Rows collection contains 10 records, the last seven of which are empty.
I set a break point in just before I call GridView.DataBind and verified that the DataTable used as the DataSource for the last page of data does in fact only contain the 3 expected records. But when I set a breakpoint on the Sub that handles the "Select" GridView command, the GridView.rows collection contains 10 records, the last 7 of which are empty.
This post[URL] and comments make note of the issue but the solution prescribed by the author does not seem to work.
Attached are some snippets of my extended GridView and the two methods from my page where I mentioned setting breakpoints above.
GridView bound to a SqlDataSource. GridView.AllowPaging is True. In one of the ItemTemplates I have a LinkButton with a OnClick event.Have a DropDownList for changing GridView.PageSize - done in Page_LoadEverything in of-course in an UpdatePanel.
The whole thing work fine (we are in test fase). The problem is that the LinkButton OnClick event is only being attached to the initial "PageSize" amount of elements. Fx. if I sat PageSize=15 in the <asp:GridView> then change the page size to say 30 from the DropDownList, the page size changes but only the first 15 LinkButtons fire the OnClick event when clicked.
I've tried to do the following:
Attached an "onchange" javascript client event for saving the selected value in a <asp:HiddenField> before postback. Problem here is that the HiddenField value is then only available on Page_Load. By then it's too late to set the new page size on the GridView because the attachemnt of events to the LinkButtons have allready happened - of-course only to the first 15 elements.Then I tried to drop the PageSize=15 in the <asp:GridView> and only sat it in the Page_load. The idea was that with no paging all the Linkbuttons will get treated evenly. That worked, but when I change the GridView page size and click fx. on LinkButton 25, the Click event forks fine but the GridView page size resets to the initial value (15) - no good.
how I can get all the LinkButtons to have their event working, even after I change GridView page size?
I have developed a application using Visual Studio 2008 and SQLServer 2008. I have a page called "Billing Center" where i need to display more than 500 records in a gridview and the gridview has sorting enabled. If i limit the page size upto 10 only the gridview performs well but user requirement is to view atleast 500 records at once which is slowing down the gridview record retrieval process.
I am using the following C# code in code behind to sorting, paging and retrieval . Please guide me what am i doing wrong in this code and how to make it work with large data set.
Part of this tutorial entails setting up a GridView which is bound to the collection of UserAccounts, and then enabling paging on the GridView. There are the usual four links for First, Prev, Next, and Last pages, which should work because I have twelve users defined, and the pagesize of my GridView set to 5. I've set up the code to enable or disable the paging links depending on what section of the entire UserGrid is currently visible.
So when I first run the website and go to the ManageUsers.aspx page, I would expect to see only the first five users in my collection. But it shows all twelve.
I must have overlooked something, but I can't find it in the text and examples.