Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > GridView and SortExpression after Column Removed

Reply
Thread Tools

GridView and SortExpression after Column Removed

 
 
=?Utf-8?B?SmFtZXMgUm9zZXdlbGw=?=
Guest
Posts: n/a
 
      02-26-2006
I'm getting an error in the following scenario.

- A GridView control is bound to an SQLDataSource.
- The user selects a column for sorting.
- Some time later in code the column used for sorting is removed and the
SelectCommand SQL changed so that the field is not returned.
- When the GridView is redisplayed an error occurs because the
GridView.SortExpression is no longer a valid column.

The SortExpression property of the GridView control is read only so it can't
be set to null or changed.

My question is how can I implement this behaviour without the error occuring?

James
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      02-27-2006
You can use the GridView.Sort method to set the sort order to a default
expression after you hide a column
http://msdn2.microsoft.com/en-us/lib...rt(VS.80).aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"James Rosewell" wrote:

> I'm getting an error in the following scenario.
>
> - A GridView control is bound to an SQLDataSource.
> - The user selects a column for sorting.
> - Some time later in code the column used for sorting is removed and the
> SelectCommand SQL changed so that the field is not returned.
> - When the GridView is redisplayed an error occurs because the
> GridView.SortExpression is no longer a valid column.
>
> The SortExpression property of the GridView control is read only so it can't
> be set to null or changed.
>
> My question is how can I implement this behaviour without the error occuring?
>
> James

 
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
Column count / Access GridView Column after DataBind Finn Stampe Mikkelsen ASP .Net 4 08-20-2010 07:25 PM
ObjectDataSource and GridView SortExpression with multiple columns problem Bogdan ASP .Net 1 07-31-2009 09:54 AM
gridview column values to another page via gridview hyperlink column Keith G Hicks ASP .Net 3 02-18-2008 06:17 AM
Setting SortExpression programmatically =?Utf-8?B?UGF1bA==?= ASP .Net 4 09-27-2005 07:54 AM
SortExpression makes SortCommand event not to trig =?Utf-8?B?UGF1bA==?= ASP .Net 0 09-22-2005 06:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57