473,386 Members | 1,741 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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...nothing 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 9494
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*********@newsgroups.nospamwrote 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...nothing 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:DataPagercontrol
- 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_LinqDataSource.aspx that demonstrates how to use
ListView, DataPager and LinqDataSource together.

(You need to change "itemContainer" to "itemPlaceholder" 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_*********@netcabo.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*********@newsgroups.nospamwrote 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...nothing 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 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.Datasource. 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.microsoft.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:DataPagercontrol
- 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_LinqDataSource.aspx that demonstrates how to use
ListView, DataPager and LinqDataSource together.

(You need to change "itemContainer" to "itemPlaceholder" 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
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...
5
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...
0
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...
1
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...
1
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...
4
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...
1
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...
2
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.