Home All Groups Group Topic Archive Search About

Sorting only certain columns in datagrid

Author
7 Nov 2005 10:26 AM
Cathryn Johns
Hi

I'm binding a dataset to my datagrid at runtime, and I want to allow
sorting only on certain columns.  How do I do this?  If I set
AllowSorting to true, all the column headers are underlined and
sortable; if I set it to false, none of them are, even if I set the
SortExpression property for the columns that I want to be sortable.

I'm sure it can be done, and it's probably easier to do it at design
time, but as I say I'm only binding the grid to the datasource at
runtime.

Author
7 Nov 2005 5:56 PM
Alvin Bruney - ASP.NET MVP
you won't be able to remove the links ahead of time without a lot of
difficulties, but one good workaround is simply to cancel the sort event if
it isn't allowed, with probably an appropriate user message.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



Show quoteHide quote
"Cathryn Johns" <cjo***@gmail.com> wrote in message
news:1131359215.019988.253970@z14g2000cwz.googlegroups.com...
> Hi
>
> I'm binding a dataset to my datagrid at runtime, and I want to allow
> sorting only on certain columns.  How do I do this?  If I set
> AllowSorting to true, all the column headers are underlined and
> sortable; if I set it to false, none of them are, even if I set the
> SortExpression property for the columns that I want to be sortable.
>
> I'm sure it can be done, and it's probably easier to do it at design
> time, but as I say I'm only binding the grid to the datasource at
> runtime.
>
Author
1 Dec 2005 7:26 AM
hkghawania
Cathryn  Johns wrote:
> *Hi
>
> I'm binding a dataset to my datagrid at runtime, and I want to allow
> sorting only on certain columns.  How do I do this?  If I set
> AllowSorting to true, all the column headers are underlined and
> sortable; if I set it to false, none of them are, even if I set the
> SortExpression property for the columns that I want to be sortable.
>
> I'm sure it can be done, and it's probably easier to do it at design
> time, but as I say I'm only binding the grid to the datasource at
> runtime. *


I am also facing the same prob. if u find out the solution please let me know.
Harry -- hkghawania ------------------------------------------------------------------------ Posted via http://www.codecomments.com ------------------------------------------------------------------------