I'm overriding the onrowcreated to add sort images to the header row of a gridview. This works, but actually adding a sortexpression doesn't. What I want to do is set the images as imagebuttons and set their commandarguments to the sort expression of the column they are sorting for.
I would assume I could get the cell and from it's index get the gridviewcolumn. Then, I could just get the sortexpression of the gridview column, but this does not work. The columns are null. OnRowCreated Code snippet below:
//if this is the header row, we add sort images to each cell
if (row.RowType == DataControlRowType.Header)
{
//iterate through the cells
for (int i = 0; i < row.Cells.Count; i++)
{
//if the column is sortable and visible
if (this.Columns[i].SortExpression != string.Empty && this.Columns[i].Visible)
{
string strSort = this.Columns[i].SortExpression;
}
}
}
Can we not get columns in OnRowCreated like this?