Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Sort Grid from Column Header and Drop Down???

Thread Tools

Sort Grid from Column Header and Drop Down???

Posts: n/a
I posted a message on the topic earlier and thought I had it solved
but in testing have found problems. I have a Templated GridView
control on a webpage bound to an ObjectDataSource. There are 3
columns that are "Sortable" That sorting works fine until I add the
dropdown with a "refresh" button into the mix. The only way that I
have found to sort the grid from the dropdown requires the following

When I set the e.Arguments.SortExpression it causes the grid to get
sorted the problem is the Grid properties do not reflect this change.
So when you next click on the grid column to sort it has the wrong
information as to which column is sorted and what direction is
sorted. So the first click on the column header the results are
unpredicable. Is there a better way to do this?

Any help would be greatly appreciated.



protected void btnRefresh_Click(object sender, EventArgs e)
sortColumn =
Convert.ToInt16(cboSortBy.SelectedValue.Substring( 0, 1));
sortExpression =

if (cboSortBy.SelectedValue.EndsWith("A"))
sortDirection = "ASC";
else if (cboSortBy.SelectedValue.EndsWith("D"))
sortDirection = "DESC";
throw new Exception("Invalid sort by Value");

protected void ObjectDataSource1_Selecting(object sender,
ObjectDataSourceSelectingEventArgs e)
if (!e.ExecutingSelectCount)
if (sortExpression != "")
e.Arguments.SortExpression = sortExpression + " "
+ sortDirection;
cboSortBy.SelectedValue =
GetSortColumnIndex().ToString() +
grdUpcoming.SortDirection.ToString().Substring(0, 1).ToUpper();


Reply With Quote

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
Grid View sort by column ASP .Net 4 08-22-2012 05:25 PM
Sort Grid from Column Header and Drop Down??? DBLWizard ASP .Net Web Controls 1 04-12-2007 07:19 AM
Fixed Header on a Data Grid using CSS - problem with Drop downs =?Utf-8?B?Sm9lIER1bmxlYXZ5?= ASP .Net 1 10-13-2005 09:09 PM
Image in header column (not replacing column header text) hansiman ASP .Net Datagrid Control 3 02-07-2004 12:17 AM
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