473,396 Members | 2,029 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,396 software developers and data experts.

Gridview Sorting with AutoGenerateColumns OFF

When I let the GridView automatically generate columns, I can allow
sorting. But when I turn autogenerate columns off, it won't allow
sorting (column names are not hyperlinks).

Is there a way I can turn sorting on when i'm not autogenerating
columns?

*** Sent via Developersdex http://www.developersdex.com ***
Jan 17 '07 #1
1 2980
You can programmatically alter a GridView.
bool addSort = true;

BoundField currentBF = new BoundField();
currentBF.DataField = "LastName";
currentBF.HeaderText = "Employee Last Name";
if (addSort)
{
currentBF.SortExpression = "LastName";
}
gv.Columns.Add(currentBF);

Be careful with the postback .
"Terry Olsen" <to******@hotmail.comwrote in message
news:uE**************@TK2MSFTNGP06.phx.gbl...
When I let the GridView automatically generate columns, I can allow
sorting. But when I turn autogenerate columns off, it won't allow
sorting (column names are not hyperlinks).

Is there a way I can turn sorting on when i'm not autogenerating
columns?

*** Sent via Developersdex http://www.developersdex.com ***

Jan 18 '07 #2

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

Similar topics

1
by: tfsmag | last post by:
Hello, I have a function that returns a dynamically created gridview. This works fine, however it does not seem to be able to maintain state when adding sorting or paging to the gridview. Does...
3
by: Thirsty Traveler | last post by:
I have a gridview where the datasource is bound after a selection. The result of doing this is that sorting and paging do not work. I was given a sample of how to resolve this, however my attempt...
0
by: jobo | last post by:
Hey there, I'm having a problem getting sorting to work. Here's what the GridView looks like: "server" ID="updt1" Mode="Conditional">
5
by: Cindy Lee | last post by:
I'm getting my data from an XML file. The data binds fine, but I can't sort on it. Do I have to do anything special? I have enabled sorting on my grid view. Autogenerate columns is off, and I...
0
by: rmgalante | last post by:
Hi, I've been experimenting with the ASP.Net GridView and encountered some interesting issues that I thought I would share. I have a page that loads a GridView with a generic collection of...
3
by: Marc Grutte | last post by:
Hi I am trying to bind a custom datasource to a gridview whilst paging is enabled. What is missing in this code to make the paging + binding work? thanks M <%@ Page Language="VB" %>
0
by: pargat.singh | last post by:
Hi: I am using a grid and having a problem with sorting. Below are my code and change the header name at run time as below based on language.If i don't change the header name it work. Can...
1
by: l3d007 | last post by:
I used this example straight from msdn in a gridview that already sorts based on each column. For some reason I cannot get it to sort based on two sorting expressions.Is there some property of the...
3
by: Nathan Sokalski | last post by:
I have a GridView control with three columns, all BoundField columns. They all have a HeaderText and DataField property set, and the third one has a DataFormatString property as well. When I run my...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.