473,724 Members | 2,236 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 9533
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
3447
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
5847
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
1063
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
1887
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
4973
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
4510
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
4917
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
3360
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
6464
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
8868
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
8741
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9388
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
8062
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5996
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
4764
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3209
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2612
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2149
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.