473,756 Members | 7,019 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataPager and ListView: Custom Datasource

How do I get the DataPager and ListView to play nice together when I use a custom datasource?

In my webpage, I use linq to pull data from a SqlServer database and assign the resulting IEnumerable<to the ListView's Datasource
property. This all works fine to display the first 3 items (the DataPager is set to display three items at a time), but when I click
on the next page in the DataPager...not hing happens. There's a roundtrip to the server, but the page doesn't update to reflect new
records.

I suspect there's some dependency between the DataPager control and the Datasource. No doubt this would all work if I used an
SqlDataSource. But I don't want to do that. The website is mostly a means for me to learn how to use linq...and after only a day of
work, there is no way I would willingly go back to the pre-linq approaches :). Besides, if Microsoft includes powerful new data
technology like linq in the Framework, there ought to be a way to have it work with at least the new data-bound controls (e.g., the
ListView).

- Mark
Jan 5 '08 #1
5 9536
if you want to control all the process you need to create a custom paging
control

with server side events its simple to control paging...
a simple control with next previous buttons that trigguers events when
clicked. And in the page that olds the grid capture the events and change
the datasource with the new data

"Mark Olbert" <Ch*********@ne wsgroups.nospam wrote in message
news:0i******** *************** *********@4ax.c om...
How do I get the DataPager and ListView to play nice together when I use a
custom datasource?

In my webpage, I use linq to pull data from a SqlServer database and
assign the resulting IEnumerable<to the ListView's Datasource
property. This all works fine to display the first 3 items (the DataPager
is set to display three items at a time), but when I click
on the next page in the DataPager...not hing happens. There's a roundtrip
to the server, but the page doesn't update to reflect new
records.

I suspect there's some dependency between the DataPager control and the
Datasource. No doubt this would all work if I used an
SqlDataSource. But I don't want to do that. The website is mostly a means
for me to learn how to use linq...and after only a day of
work, there is no way I would willingly go back to the pre-linq approaches
:). Besides, if Microsoft includes powerful new data
technology like linq in the Framework, there ought to be a way to have it
work with at least the new data-bound controls (e.g., the
ListView).

- Mark

Jan 6 '08 #2
Hi Mark,

Please see following example:

#The asp:ListView control (Part 1 - Building a Product Listing Page with
Clean CSS UI) - ScottGu's Blog
http://weblogs.asp.net/scottgu/archi...view-control-p
art-1-building-a-product-listing-page-with-clean-css-ui.aspx
<blockquote>
One of the other new controls in ASP.NET 3.5 is the <asp:DataPagerc ontrol
- which makes data paging scenarios with the ListView control pretty easy.
You can drop it anywhere you want on a page, and set its "PagedControlID "
property to point at the ListView, and its "PageSize" property to indicate
how many items in the ListView you want displayed at a time
</blockquote>
It has an example Products_LinqDa taSource.aspx that demonstrates how to use
ListView, DataPager and LinqDataSource together.

(You need to change "itemContai ner" to "itemPlaceholde r" in the ListView
markup, the example was written before .NET 3.0 RTMed).

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 7 '08 #3
Yep, that's what I did. But it seems inelegant.

- Mark

On Sun, 6 Jan 2008 13:50:26 -0000, "Toze" <m_*********@ne tcabo.ptwrote:
>if you want to control all the process you need to create a custom paging
control

with server side events its simple to control paging...
a simple control with next previous buttons that trigguers events when
clicked. And in the page that olds the grid capture the events and change
the datasource with the new data

"Mark Olbert" <Ch*********@ne wsgroups.nospam wrote in message
news:0i******* *************** **********@4ax. com...
>How do I get the DataPager and ListView to play nice together when I use a
custom datasource?

In my webpage, I use linq to pull data from a SqlServer database and
assign the resulting IEnumerable<to the ListView's Datasource
property. This all works fine to display the first 3 items (the DataPager
is set to display three items at a time), but when I click
on the next page in the DataPager...not hing happens. There's a roundtrip
to the server, but the page doesn't update to reflect new
records.

I suspect there's some dependency between the DataPager control and the
Datasource. No doubt this would all work if I used an
SqlDataSourc e. But I don't want to do that. The website is mostly a means
for me to learn how to use linq...and after only a day of
work, there is no way I would willingly go back to the pre-linq approaches
:). Besides, if Microsoft includes powerful new data
technology like linq in the Framework, there ought to be a way to have it
work with at least the new data-bound controls (e.g., the
ListView).

- Mark
Jan 7 '08 #4
Walter,

The example doesn't answer my question because it depends on using the LinqDataSource, which is fine when you just want to pull data
from a single table but doesn't work for more complex queries. As an aside, it would be nice to know if there are plans to extend
the LinqDataSource control so that it acts more like the SqlDataSource control (i.e., supports more complex SELECT queries).

Basically, what I'm doing (in the code behind) is this:

1) Retrieve data from database using LINQ
2) Assign retrieved results to ListView.Dataso urce. The ListView has an associated DataPager control.
3) Databind() ListView

Paging does not work in this situation.

I think paging requires the use of a LinqDataSource (or SqlDataSource) control to work. I'd like to confirm that.

- Mark

On Mon, 07 Jan 2008 08:12:51 GMT, wa****@online.m icrosoft.com ("Walter Wang [MSFT]") wrote:
>Hi Mark,

Please see following example:

#The asp:ListView control (Part 1 - Building a Product Listing Page with
Clean CSS UI) - ScottGu's Blog
http://weblogs.asp.net/scottgu/archi...view-control-p
art-1-building-a-product-listing-page-with-clean-css-ui.aspx
<blockquote>
One of the other new controls in ASP.NET 3.5 is the <asp:DataPagerc ontrol
- which makes data paging scenarios with the ListView control pretty easy.
You can drop it anywhere you want on a page, and set its "PagedControlID "
property to point at the ListView, and its "PageSize" property to indicate
how many items in the ListView you want displayed at a time
</blockquote>
It has an example Products_LinqDa taSource.aspx that demonstrates how to use
ListView, DataPager and LinqDataSource together.

(You need to change "itemContai ner" to "itemPlaceholde r" in the ListView
markup, the example was written before .NET 3.0 RTMed).

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

============== =============== =============== ======
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============== =============== =============== ======

This posting is provided "AS IS" with no warranties, and confers no rights.
Jan 7 '08 #5
Hi Mark,

I think in this case, the custom data source must support paging. The
DataPager needs this to support paging. In LINQ for SQL, I believe you can
use Take() and Skip() to implement paging support.

For feature request about LinqDataSource, please feel free to submit at
http://connect.microsoft.com/Main/co...ContentID=2220.
Thanks.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 9 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3448
by: newbie | last post by:
Hello, I maybe asking too much in a single posting, but here it goes: I building a windows form that mimic's the Outlook XP GUI. Its a three pane form that will allow a user to view and edit records in a database. A Treeview in the left pane, a Listview in the TopRight Pane, and a PropertyGrid in the BottomRight; The Treeview will allow the user to select an "Entity" to view, the listview will display a list of instances of
5
5848
by: ToddH | last post by:
I know the following code is C#. I'm a vb programmer trying to learn a new language. I posted this in the c# group but never got a response. You guys seem to know alot about all languages and have all the answers, so here it is.. I'm trying to create a custom listview that uses custom listviewitems. The listviewitems persist just fine in design mode. However, when I build the solution, the listview item doesn't show up. I've run some tests,...
0
1064
by: shapper | last post by:
Hello, I am using the new ASP.NET 3.5 ListView and DataPager. Everything is working fine but I am getting a strange behavior in the DataPager. When I click a pager button for the first time nothing happens. When I click the second time it starts to work.
1
1889
by: =?Utf-8?B?TmVkaW0=?= | last post by:
Is it possible to use DataPager with custom loading classes (I use my own queries because of filtering and paging) and ListView control? ListView control is bound to a DataReader and DataReader method accepts page number and page size? Is there a way to make DataPager use my values and methods?
1
4975
by: shapper | last post by:
Hello, I am using a DataPager with a ListView. I am creating everything at runtime. I need to create a custom DataPager so that the numbers and the next previous symbols will be inside a list (ul li). How can I do this?
4
4515
by: Brian Gaze | last post by:
I have created a ListView control and have bound this to a datasource. Within the ItemTemplate of the ListView I have added another ListViewControl which is databound in the code behind. The idea is that when clicking on the "Show details" button the ListView for the appropriate row binds in the codebehind and displays the detail data for the selected row. I did something similar with a gridview control previously, but want to be able to...
1
4920
by: bharathreddy | last post by:
Hi, I am using listview control for display. And I am using LINQ for binding the datasource to the listview control at the codebehind. I have implemented the paging in the listview control using the DataPager. But its not working properly. Whn I am clicking twice then i am able to navigate to the next page. I tried to bind the data in the prerender event but that too doesnt working. Why can this be happening. Can any one...
2
3363
by: =?Utf-8?B?UGhpbGlw?= | last post by:
I am attempting to insert a simple record with LinqDataSource from a ListView, however I always get a message saying "....LinqDataSource 'dataSource' has no values to insert. Check that the 'values' dictionary contains values...." I am using a ListView with a DataSourceID of a LinqDataSource. When a new row icon is clicked....the ListView properly enters into the InsertItemTemplate....however when the ImageButton with a CommandName of...
2
6465
by: sundaramails | last post by:
I am using DataPager in ListView. I put ListView In Infragistics Asynchronous Refresh Panel & Datapager in Update Panel. I have a button in Listview control(Run by client Script). When i click the button data pager shows twice in listview. Also data pager number when i click second time thatz run? Please Help...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.