Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Linq data source selecting and sort

Reply
Thread Tools

Linq data source selecting and sort

 
 
Chuck
Guest
Posts: n/a
 
      02-11-2010
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.


 
Reply With Quote
 
 
 
 
Vince Xu [MSFT]
Guest
Posts: n/a
 
      02-12-2010
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/archi...-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/subs...#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/subs.../aa948874.aspx
==================================================
--------------------
| Thread-Topic: Linq data source selecting and sort
| thread-index: AcqrZ8sXkM7ZlmAIRzCZYN5crffNug==
| X-WBNR-Posting-Host: 192.12.184.2
| From: Chuck <(E-Mail Removed)>
| Subject: Linq data source selecting and sort
| Date: Thu, 11 Feb 2010 14:16:01 -0800
| Lines: 19
| Message-ID: <(E-Mail Removed)>
| 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.webcontro ls
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontro ls:5080
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
|
| 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.
|
|
|

 
Reply With Quote
 
 
 
 
Vince Xu [MSFT]
Guest
Posts: n/a
 
      02-16-2010
Hi,

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

Vince Xu

Microsoft Online Support

--------------------
| X-Tomcat-ID: 75046067
| References: <(E-Mail Removed)>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: http://www.velocityreviews.com/forums/(E-Mail 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.webcontro ls
| Message-ID: <(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
| Lines: 82
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontro ls: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/archi...-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/subs...#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/subs.../aa948874.aspx
| ==================================================
| --------------------
| | Thread-Topic: Linq data source selecting and sort
| | thread-index: AcqrZ8sXkM7ZlmAIRzCZYN5crffNug==
| | X-WBNR-Posting-Host: 192.12.184.2
| | From: Chuck <(E-Mail Removed)>
| | Subject: Linq data source selecting and sort
| | Date: Thu, 11 Feb 2010 14:16:01 -0800
| | Lines: 19
| | Message-ID: <(E-Mail Removed)>
| | 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.webcontro ls
| | Path: TK2MSFTNGHUB02.phx.gbl
| | Xref: TK2MSFTNGHUB02.phx.gbl
| microsoft.public.dotnet.framework.aspnet.webcontro ls:5080
| | NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
| |
| | 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.
| |
| |
| |
|
|

 
Reply With Quote
 
Chuck
Guest
Posts: n/a
 
      02-26-2010
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is selecting column, filtering , sorting, paging is done in database or memory when use linq to sql? Ryan Liu ASP .Net Web Controls 0 12-12-2008 06:40 PM
Linq or not Linq George ASP .Net 4 11-05-2008 04:53 PM
Finding and selecting a record in a gridview with paging and sortingenabled (using LINQ) Mike N. ASP .Net 0 07-31-2008 04:55 PM
Finding and selecting a record in a gridview with paging and sortingenabled (using LINQ) Mike N. ASP .Net 0 07-31-2008 04:47 PM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments