Paging Not Working With ListView And WebService Using Linq
Dec 20, 2010
I have a simple page that looks up contacts using a webservice with a single method written in Linq. On the page, I have both a gridview and a listview with a DataPager to compare the two. I can get paging working just fine with the gridview, but the Linq code has to return all of the data on each call and let the web page pick out only a page's worth... not the best solution. I have been told that a ListView will solve this problem, but all the examples I have been able to find have the Linq code on the web page instead of in a separate layer (e.g. a webservice). Ideally, I should be able to tell the web service to bring back a specific page worth of data (starting record number and number of rows), but how do I get the ListView (or the DataPager) to fire an event that asks for this data?
Here is the ASPX code:
<asp:ListView ID="listPersons" runat="server"> <LayoutTemplate>
<table> <thread> <tr> <th> Site ID </th> <th> PersonID </th>
<th> Person Name </th> </thead> <tbody>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" /> </tbody> </table>
<asp:DataPager ID="Pager1" runat="server" PagedControlID="listPersons" PageSize="5" > <Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="true" ShowPreviousPageButton="true" ShowNextPageButton="false" ShowLastPageButton="false" /> <asp:NumericPagerField />
<asp:NextPreviousPagerField ShowFirstPageButton="false" ShowPreviousPageButton="false" ShowNextPageButton="true" ShowLastPageButton="true" />
</Fields> </asp:DataPager> </LayoutTemplate> <ItemTemplate><tr> <td> <%# Eval("SiteID") %>
</td> <td> <%# Eval("PersonID") %> </td> <td> <%# Eval("PersonName") %> </td>
</tr> </ItemTemplate> <EmptyDataTemplate> No data found... </EmptyDataTemplate> </asp:ListView>
Here's the code behind:
private void DoList(string Match) {
ContactsService cs = new ContactsService();
listPersons.DataSource = cs.Find(Match, 100 ); listPersons.DataBind(); }
and the web serivice:
[WebMethod]
public List<Person>Find(string Match, int Count) { if (Count < 5) Count = 5;
using (DataLayer.ContactsDataContext context = new ContactsDataContext()) {
var Persons = from p in context.Persons where p.PersonName.Contains(Match)
orderby p.LastName, p.FirstName select new Person() {
SiteID = p.SiteID, PersonID = p.PersonID, PersonName = p.PersonName, };
return Persons.Take(Count).ToList(); } }
View 1 Replies
Similar Messages:
Sep 24, 2010
I have a listview nested inside a gridview.
I'm trying to get paging working on the listview. I thought that it would display the paging controls, and just page through them normally.
It does display the controls, and limits the result set shown to the appropriate number of records (pageSize) but when I click on the paging controls the grid refreshes and nothing changes with the nested listview (it's still on the first page).
I've tried nesting the listview inside an updatepanel, but the behavior remains. The gridview itself is already in an updatepanel.
So this is the layout I've got:
[code]....
View 2 Replies
Dec 27, 2010
I have a listview that I'm binding programmatically. I am trying to add a simple datapager but the paging is not working. it is because I am binding programmatically.
[Code]....
View 2 Replies
Jan 6, 2011
I have a Listview with a LinqDataSource. I am allocating a resoure called Bladder Scanners to clinicians on the day selected. The field in the database, 'Allocated_Bladder_Scanner_Id', allows nulls. The 'nullable' property of the field in the dbml is set to allow nulls.In the edit template, I have an unbound dropdownlist (drpBladderScannerDropdown) with an 'empty string' item added to cater for nulls, and
AppendDataBoundItems="true".In order to show only bladder scanners which have not yet been allocated on the selected day, I am databinding the dropdownlist to a dictionary of unallocated bladder scanners in the ItemDataBound event. I then add the currently selected bladder scanner as a listitem and set it as the selected item. So far, so good, all works well. However, if the clinician has a bladder scanner currently allocated, and then the user elects to not allocate the clinician a bladder scanner on that day by selecting 'Nothing' from the dropdownlist, the LinqDataSource fails to update the field. It does not throw an exception, it just doesn't set the field to nulls. In ItemUpdating I have the following code:
[Code]....
View 1 Replies
Oct 10, 2010
So I am using EW + Access database to create a page.
This page contains two controls. First control is Dropdownlist which databinds with second control Listview.
This listview has paging on becuse of multiple pages. If I don't use QueryStringField paging works but if I use QueryStringField paging doesn't work and it goes back to first option of Dropdownlist.
View 17 Replies
Oct 6, 2010
I am struggling to create a webservice method using LINQ technology and to populate a dropdown in a form. Here is the Webservice code.
[WebMethod]
public
string[] GetAllCountries()
{
LinqClassesDataContext db =
new
LinqClassesDataContext();
var q =
from c
in db.ListContinents()select
c;
return q.ToList() ;
}
And here is the form code behind
protectedvoid
Page_Load(object sender,
EventArgs e)
{
WSClass WS =
new
WSClass();//bool
ds = WS.GetAllCountries();
var v = WS.GetAllCountries();
ddlContinent.DataSource = v;
ddlContinent.DataBind();
}
View 5 Replies
Jan 19, 2010
i have application with 2 cascading dropdownlists that got populated using web service, when a value was picked in the first one the second filled with values, now when the second one got selected i want to poulate listview with images links.
View 2 Replies
Feb 23, 2010
Every time you search for post on SOF, you can browse through the result with page-navigation feature. How do I create a Paging feature like SOF?
View 2 Replies
Apr 14, 2010
I'm using a datapager control on my listview to perform paging in it.
When paging through the table, I need to perform some validations. When these validations are not successfull, the paging should be cancelled.
I currently perform the validation in the PagePropertiesChanging event of the ListView, however, the arguments do not provide a Cancel property.
protected void MyListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
if (!Validate())
{ // cancel the paging action}
}
View 2 Replies
Oct 5, 2010
I am retrieving data from sql database. I want to split the records and binding it in three different grids. Everything is working fine before applying paging. I am getting The data source does not support server-side data paging. error
Code:
DataTable StoreDisplayTypeList = storeDisplayBL.GetStoreDisplayDetails();
var specialBook = from myRow in StoreDisplayTypeList.AsEnumerable() where (string)myRow["StoreDisplayType"] == "Special Book" select myRow;
var newRelease = from myRow in StoreDisplayTypeList.AsEnumerable() where (string)myRow["StoreDisplayType"] == "New Release" select myRow;
var Seller = from myRow in StoreDisplayTypeList.AsEnumerable() where (string)myRow["StoreDisplayType"] == "Best Seller" select myRow;
var featuredEdition = from myRow in StoreDisplayTypeList.AsEnumerable() where (string)myRow["StoreDisplayType"] == "Featured Edition" select myRow;
this.gvBestSeller.DataSource = Seller;
this.gvBestSeller.DataBind(); // Error
this.gvNewRelease.DataSource = newRelease;
this.gvNewRelease.DataBind(); // Error
this.gvSpecialBook.DataSource = specialBook;
this.gvSpecialBook.DataBind(); // Error
this.gvFeaturedREdition.DataSource = featuredEdition;
this.gvFeaturedREdition.DataBind(); // Error
View 1 Replies
Feb 11, 2011
I'd like take both C# and VB.NET suggestion. I have a simple ListView with DataPager like the following:
<asp:ListView ID="lvStudent" runat="server">
<LayoutTemplate>
<table id="TimeSheet" cellspacing="1" class="tablesorter">
[code]...
View 1 Replies
Nov 9, 2010
In my asp.net page I have a listview that has a datapager defined in the LayoutTemplate.The listview is databound to a list of records. I know the total number of records ... but I don't load them from the db. I want to tell the pager at first request the total number of records and let it generate the pages and navigation. When the user click a page from the datapager I want to load the records from the db and update the listview binding to display results from that page. Is this possible with the listview and datapager from asp.net?
View 3 Replies
Nov 1, 2012
I was wondering if there were any decent tutorials on paging the records in a ListView using a DataPager (Pager Control). I can get it to work with Drag and Drop but I can't seem to find a decent tutorial on doing it programmatically.
View 1 Replies
May 29, 2010
I just wana know that can I bind an asp listview via javascripts by calling a webservice in c#??
View 2 Replies
Feb 7, 2010
How can i implement Custom Paging for ListView control using row_number in sql server 2005 stored procedure.
View 2 Replies
May 17, 2010
I have a listview and would like to scroll the ItemTemplatei instead of using paging. I need to freeze the header and InsertTemplate row, and works accross browsers. I've tried the following link:
[URL]
but am having problems getting it to work accross browsers I can get it to work in FF or IE6 but not both.
is there another control rhat's more suitable for this than the ListViiew?
View 2 Replies
May 13, 2013
i am applying paging in list view. i used data pager control. but problem is on click of next page next data is not displaying only showing previous data. i have one dropdown i am bing list view on dropdownindex change event not in page load.
<div id='main-content' style="overflow: auto; width: 100%" class="printable">
<asp:ListView ID="LSVAllSlips" runat="server" GroupItemCount="2" GroupPlaceholderID="groupPlaceholder1"
ItemPlaceholderID="itemPlaceholder1" OnPagePropertiesChanged="LSVAllSlips_PagePropertiesChanged">
<LayoutTemplate>
<table>
<tr id="Tr1" runat="server">
[code]...
View 1 Replies
Jun 1, 2010
Now I know there is a reason to this odering but my tiny little brain can't get my head around it.I am using a webservice to pull through data to a webp[age and have the following that is so far pulling data through from UUF1:
public string[] GetBuyer(string Memberkey)
{
try
[code]...
View 2 Replies
Apr 13, 2010
I'm using a datapager control on my listview to perform paging in it.When paging through the table, I need to perform some validations. When these validations are not successfull, the paging should be cancelledI currently perform the validation in the PagePropertiesChanging event of the ListView, however, the arguments do not provide a Cancel property.
[Code]...
View 6 Replies
Mar 19, 2010
I've got a big problem here with the ListView control. Basically I've got very basic code, yet it seems to break the control completely.
Here's the deal, I got a simple ListView using an ItemTemplate containing a hyperlink. Obviously the hyperlink has to lead somewhere after clicking, so the datakeys enter the scene since I need to hook up a hyperlink containing the Id of the record it's in as a parameter.
Normally this shouldn't be a problem, so in the itemcreated event I look up the link control and add the url using data foud in the datakeys.So far so good, this all works out fine.
Now this contains a number of records, too many to display on one page, so I decided to implement paging by using a DataPager, which is the way to get the ListView to support paging. This didn't work.
After a little tinkering around with the code, I found that if I didn't get any datakeys in the itemcreated event, that it all works fine. However, I need to use the datakeys or I won't be able to hook up a url to the hyperlink.
Basically, that one line of code completely kills paging. Commenting it out immediately sets things right, but that's not an option.
[Code]....
View 4 Replies
Jan 31, 2011
If I disable the ViewState on a ListView, the events raised by it are no longer ired. OnPagePropertiesChanging is the ListView event I've always used in combination with the DataPager to update the ListView to the correct page once a DataPager item is clicked, but since its not being fired, I'm wondering if there are any other options. My ListView is currently in an UpdatePanel, and I'm caching the results that the ListView is being bound to. I could rebind the cached results on the PageLoad, but I can't think of a good way to determine if the PageLoad is being accessed because the DataPager was clicked, or for some other reason, so this doesn't seem like a good idea
View 2 Replies
May 6, 2014
I am developing a list page, for exp hotellist , in mvc razor 4 visual studio 2012 ... i use foreach to show list in view from actionresult...how to use paging 1 2 3 4 ............ to keep limit for number of records each page.. can i use paging directly.Â
View 1 Replies
Jan 24, 2011
It has been more than 2 days since I had started searching for the answer and I still don't know how to do it.
I have empty gridview that is filled with data depending of the parameters given. The gridview is used to track changes user had made to the database.
In the first dropdown list the user selects from which table (or all tables) to display the data. From the second dropdown list the user selects from which column (or all columns) of the previously selected table to display data. In the first textbox the user enters the search term and in the third and fourth textboxes the user enters the date range in which the changes occurred.
After clicking button the data within the given parameters should be displayed. The problem is that data is displayed fine, but I can't manage to get sorting and paging to work so if possible, give concrete answer because I'm pretty sure I googled one half of the web during these 2 days. :)
Here is the code for the .aspx file:
[Code]....
Here is the codebehind:
[Code]....
To sum everything up... My question is: "How to enable sorting and paging for this code?"
View 3 Replies
Aug 27, 2010
I am looking for a way to do paging with a GridView when i set the datasource at run time using a linq query. here is my code:
ETDataContext etdc = new ETDataContext();
var accts = from a in etdc.ACCOUNTs
orderby a.account_id
select new
{
Account = a.account_id,
aType = a.SERVICEs.FirstOrDefault().SERVICE_TYPE.service_type_desc,
name = a.SERVICEs.FirstOrDefault().service_name,
[Code]....
But that works well when you use a datatable but not with linq. If I add a rebind in the event, it has to requery 7000 records which can be a little slow. Does anyone know how to fix the paging when using linq like this?
View 1 Replies
May 21, 2010
I mean, what is the faster way to get as fast as I can more than one table with stored procedure? Is there any study what is faster and why? There is a big problem getting more than one table at once with Entities, so the only way is DataSet. But I was told DataSet work very slow. Is that true?
View 2 Replies