Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Datagrid e.SortExpression is wrong

Reply
Thread Tools

Datagrid e.SortExpression is wrong

 
 
therien.mike@gmail.com
Guest
Posts: n/a
 
      06-09-2006
I have a Datagrid with the first 4 columns as blank and without a Sort
Expression set. The remaining columns have the Sort Expression set.

The page stores a ViewState variable named "CurrentSort", that contains
the sort expression the user last selected. When the page is initially
loaded, this value is set to "ID", which is not one of the sort
expressions in my DataGrid.

I have the following code that generates and Up/Down arrow depending on
the sort:

(ItemCreated event)...
if (e.Item.ItemType == ListItemType.Header)
{
for (int i=0; i < this.dgData.Columns.Count; i++)
{
if (this._currentSort ==
this.dgData.Columns[i].SortExpression)
{
TableCell cell = e.Item.Cells[i];
System.Web.UI.HtmlControls.HtmlImage imgArrow = new HtmlImage();
imgArrow.Src =(this._sortDirection==enuSortDirection.soAscendin g ?
"images/up.gif" : "images/dn.gif");
imgArrow.Alt = (this._sortDirection==enuSortDirection.soAscending ?
"Sorted in Ascending order" : "Sorted in Descending order");
cell.Controls.Add(imgArrow);
break;
}
}

On initial load, no arrow is produced because the initial sort order is
not a column.

When the user clicks on a column, SortCommand is raised with the passed
e.SortExpression. The problem is, when the above code produces an
arrow, the column that is returned with the SortCommand event is for
the the next column in the grid, (Column ID + 1) instead of the column
that was clicked. If the above code did not produce an arrow, then
everything works fine.

I was able to determine that when the grid is generated with an arrow,
the "link" in the status bar shows "...ctl{#}..." where the {#} of the
column is correct when no arrow is present and column + 1 when an arrow
is present. It seems to add a number when I add an arrow.

This is all done in .Net 1.1.xxxx

Thanks to anyone that can shed some light on this problem...

Thanks,
Mike

 
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
Is XML Doc wrong or is Schema wrong? (or both) Matthew XML 7 01-07-2005 10:05 PM
Wrong event fires in my asp.net datagrid Hannes ASP .Net 3 08-19-2004 06:53 PM
What am I doing wrong? (Datagrid) Kristoffer Arfvidson ASP .Net 4 01-30-2004 10:48 PM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM
Adding to a Bound DataGrid: What the @#$!% am I doing wrong! Aaron Ackerman ASP .Net 2 07-29-2003 07:31 AM



Advertisments