T
therien.mike
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.SortExpression)
{
TableCell cell = e.Item.Cells;
System.Web.UI.HtmlControls.HtmlImage imgArrow = new HtmlImage();
imgArrow.Src =(this._sortDirection==enuSortDirection.soAscending ?
"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
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.SortExpression)
{
TableCell cell = e.Item.Cells;
System.Web.UI.HtmlControls.HtmlImage imgArrow = new HtmlImage();
imgArrow.Src =(this._sortDirection==enuSortDirection.soAscending ?
"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