Linq data source selecting and sort

C

Chuck

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.
 
V

Vince Xu [MSFT]

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 <[email protected]>
| Subject: Linq data source selecting and sort
| Date: Thu, 11 Feb 2010 14:16:01 -0800
| Lines: 19
| Message-ID: <[email protected]>
| 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
|
| 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.
|
|
|
 
V

Vince Xu [MSFT]

Hi,

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

Vince Xu

Microsoft Online Support

--------------------
| X-Tomcat-ID: 75046067
| References: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (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: <[email protected]>
| 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
|
| 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 <[email protected]>
| | Subject: Linq data source selecting and sort
| | Date: Thu, 11 Feb 2010 14:16:01 -0800
| | Lines: 19
| | Message-ID: <[email protected]>
| | 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
| |
| | 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.
| |
| |
| |
|
|
 
C

Chuck

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.
 

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

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top