DataGrid strange behaviour

S

Stefano Mostarda

Hi there,

I have a problem.

I've a grid where sort is enabled.

I've handled the datagrid itemcreated event. In the code I add a bitmap
to the header of the column selected by the user.
Here's the code:

int i;
System.Web.UI.WebControls.Image imSortBitmap

if (e.Item.ItemType == ListItemType.Header){
for (i=0; i<grUser.Columns.Count; i++){
if (FSortExpressions == grUser.Columns.SortExpression){
imSortBitmap = new System.Web.UI.WebControls.Image();
imSortBitmap.ImageUrl = "images/" + ((stUserSearchField.SortOrder
== "DESC") ? "SortDesc.Gif" : "SortAsc.Gif");
e.Item.Cells.CssClass = "SelectedHeader";
e.Item.Cells.Controls.Add(imSortBitmap);
}
else{
grUser.Columns.HeaderStyle.CssClass = "Header";
}
}
}

I've handled the datagrid sortcommand event.
Here's the code

BindGrid(Convert.ToString(e.SortExpression));

The problem is that in the sortcommand event the e.SortExpression return
the sort expression of the column next to the one the user has selected.
If I comment the line which adds the bitmap to the cell in the
itemcreated event everything works fine.

Any ideas?

Thanks in advance
Stefano Mostarda MCP
Rome Italy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top