LINQ Videos

A

Alex. O. Koranteng

I have downloaded LINQ Video tutorials CS code version from MSDN learning
link: http://msdn.microsoft.com/en-us/library/bb397906.aspx. The zipped file
for the download is Samplecode-LINQ-To-SQL-Video-Part03-Csharp.zip. I can get
the gridview to display the products but the sorting is not working. I get
the following error message for paging and sorting. Any suggestions will be
appreciated

Server Error in '/' Application
--------------------------------------------------------------------------------

The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.



Server Error in '/' Application
--------------------------------------------------------------------------------

The GridView 'GridView1' fired event Sorting which wasn't handled.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Web.HttpException: The GridView 'GridView1' fired
event Sorting which wasn't handled.
 
S

Steven Cheng

Hi Alex,

From your description, you're encountering some problem when try using LINQ
in ASP.NET web page and perform paging, correct?

As for the Gridview and LINQ paging, are you direcly using LinqDatasource
to bind data with Gridview? If so, you can directly bind the LINQ generated
data context to LinqDatasource and use it with Gridview control. What you
need is just set Gridview's "AllowPaging" and "PageSize" which can be done
via Visual Studio design-time surface.

Here is a simple example aspx page which use Gridview and LINQDataSource to
display "JobCandidates" table in AdventureWorks sample database

=================
<form id="form1" runat="server">
<div>

<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="WebApplication1.TestDBDataContext"
TableName="JobCandidates">
</asp:LinqDataSource>

</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataKeyNames="JobCandidateID"
DataSourceID="LinqDataSource1" PageSize="3">
<Columns>
<asp:BoundField DataField="JobCandidateID"
HeaderText="JobCandidateID"
InsertVisible="False" ReadOnly="True"
SortExpression="JobCandidateID" />
<asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID"
SortExpression="EmployeeID" />
<asp:BoundField DataField="ModifiedDate"
HeaderText="ModifiedDate"
SortExpression="ModifiedDate" />
</Columns>
</asp:GridView>
</form>
=====================

Based on the exception, error message you provided, it seems you're
manually handle the paging or sorting. If so, you can have a look at the
following thread:

http://forums.asp.net/p/956540/1177923.aspx#1177923

and for using custom ObjectdataSource and LINQ datacontext to page
Gridview, you can also refer to the following articles:


#LINQ to SQL Paging using GridView in C# and ASP.NET 3.5
http://www.dbtutorials.com/display/linq-to-sql-paging-cs.aspx

http://borrell.parivedasolutions.com/2008/01/objectdatasource-linq-paging-so
rting.html

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 
A

Alex. O. Koranteng

Steve,

Thanks for links and suggestions. I was of the the impression that the linq
sample videos will work right out of the box. I will implement your code and
update you early next week. If that works, then I will escalate it to the
LINQ sample video tutorial.. Have a happy new year

Alex
 
S

Steven Cheng

Thanks for your reply Alex,

How is everything going on?
Is there anything else we can help? If so, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).



--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
References: <[email protected]>
 
A

Alex. O. Koranteng

Steve,

I am still having problems with sample code for the LINQ-Video#3 CS version
download and will will attach a zipped file of the sample code for your
review. Could you kindly let me know what your email address is and will
forward it to you. In the meantime, I will try the code listing you sent me
to see how things work. I am interested in this technology

Thanks
 
S

Steven Cheng

Thanks for your reply Alex,

Sure. You can reach me through the following address:

"stcheng" @ "microsoft.com"

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.



--------------------
 
A

Alex. O. Koranteng

Steve,

I have emailed to you the zipped file for your review. Thanks for all your
support.
 
S

Steven Cheng

Hi Alex,

I've tested the project you provided. The problem is due to those "paging"
and "sorting" event not be handled (for the GridView). When you're not
using DataSource control to supply datasource, you need to manually handle
those events(define event handlers). I've made changes in the page and the
modified project is in attachment.

In addition, here are some articles which provide some further information
about Gridview manual sorting/paging mechanism.

#Manually sorting and paging Gridview without using datasource control
http://weblogs.asp.net/vikram/archive/2008/04/15/manually-sorting-and-paging
-gridview-without-using-datasource-control.aspx

#HOW TO: Using sorting / paging on GridView w/o a DataSourceControl
DataSource
http://forums.asp.net/t/956540.aspx

Also, the ASP.NET dataaccess tutorial is very helpful on standard ASP.NET
databinding startup:

http://www.asp.net/learn/data-access/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).


--------------------
 
A

Alex. O. Koranteng

Steve,

Thanks for all your support. I will go through the attached file and update
you before weekend
 
S

Steven Cheng

Thanks for your followup Alex,

I'm glad that you've got it working.

Have a nice day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed)..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top