Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Linq data source selecting and sort

4 views
Skip to first unread message

Chuck

unread,
Feb 11, 2010, 5:16:01 PM2/11/10
to
I have a grid with a LinqDataSource.
In the linqdatasource.selecting event I
use e.Result =( a linq query).
I do this because I have one aspx page where I return a query with different
columns based on what the user wants to see. The grid has autocolumns
selected. Thus I change the columns and query at runtime.

The problem I have is if I enable sorting, I get an exception if I change
the linq query to one with different columns after a postback.

Essentially in the LinqDataSource1_Selecting LinqDataSourceSelectEventArgs e
e.Arguments.sort.expression has a value that contains a column that is not
in the new linq query and it barfs.

Is there a way to clear this value on a postback.
I tried reseting the Grids datasource and nulling the LinqDataSource, but
nothing worked.


Vince Xu [MSFT]

unread,
Feb 12, 2010, 1:57:41 AM2/12/10
to
Hi,
What's error you got if you change the Linq query to one with different
colums after postback?

Why you need reset the LinqDatasource? It sounds you had better build a
Datasource object by Linq dynamically, don't you?

http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-
the-linq-dynamic-query-library.aspx

Does that make sense?

--
Sincerely,

Vince Xu

Microsoft Online Support


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

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
==================================================
--------------------
| Thread-Topic: Linq data source selecting and sort
| thread-index: AcqrZ8sXkM7ZlmAIRzCZYN5crffNug==
| X-WBNR-Posting-Host: 192.12.184.2
| From: Chuck <nosp...@nospam.nospam>
| Subject: Linq data source selecting and sort
| Date: Thu, 11 Feb 2010 14:16:01 -0800
| Lines: 19
| Message-ID: <EA9BEBCA-E70F-41A2...@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4325
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:5080
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

Vince Xu [MSFT]

unread,
Feb 16, 2010, 2:01:38 AM2/16/10
to
Hi,

Since I didn't get your response. Is that helpful for you?
--
Sincerely,

Vince Xu

Microsoft Online Support

--------------------
| X-Tomcat-ID: 75046067
| References: <EA9BEBCA-E70F-41A2...@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: v-vi...@online.microsoft.com (Vince Xu [MSFT])
| Organization: Microsoft
| Date: Fri, 12 Feb 2010 06:57:41 GMT
| Subject: RE: Linq data source selecting and sort
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| Message-ID: <ptxBxC7q...@TK2MSFTNGHUB02.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| Lines: 82
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:5081
| NNTP-Posting-Host: tk2tomimport1.phx.gbl 10.230.18.247

Chuck

unread,
Feb 26, 2010, 12:01:01 AM2/26/10
to
The error is column not found because the column is not their anymore.
You can do dyanmic queries but if you omit a column then somewhere the
datasource is remembering the sort and tries to append the now missing coumn
to the query and it produces the error message.

Sorry for the late response, every month or two my notifications to
responses on the forums and newsgroups stop.

0 new messages