473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

GridView and SortExpression after Column Removed

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
Feb 26 '06 #1
1 2259
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

Feb 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
1
by: Wayne Wengert | last post by:
I have a Gridview bound to an SQLDataSource (see code below). The value of the "DayOfWeek" column is actually an integer where 0 = Daily, 1=Sunday, 2=Monday, etc. How can I change what is displayed...
0
by: jeffmagill | last post by:
Hi Everybody, I'm really hoping that someone can help me out because I have spent too much time on this project already! Basically, I have a DetailsView that handles all the Edits for a...
1
by: Eric | last post by:
I have a GridView control that I want to sort on multiple columns when I click a particular column. For example, I display Last name + ", " + First name in the first column and display id in the...
1
by: msch-prv | last post by:
I have difficulties adjusting the column width of a gridview control. The column width changes appear in the design grid, but at run-time the width changes back to what I presume are the grid's...
1
by: Bill44077 | last post by:
I am dynamically adding a checkbox in a gridview and I find there are several things that I cannot figure out how to address. 1. The width of the checkbox column is very wide. I've tried adding...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
0
by: rajendrsedhain | last post by:
I have problem on Gridview column sorting.I want to sort each column when click to the column head.I implemented the 'GridView1_Sorting methond by using viewstate and in this way below. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.