I found an alternative solution for these situation,I want to share it with you
First I added theses lines for my CSS file :
.SortedAscendingHeaderStyle, .SortedDescendingHeaderStyle
{
background-color: #FFFFCC;
background-repeat: no-repeat;
}
.SortedAscendingHeaderStyle
{
background-image: url(Controls/Images/arrow_up.png);
}
.SortedDescendingHeaderStyle
{
background-image: url(Controls/Images/arrow_down.png);
}
then I added a new function to return the index of the sorted column as following :
Private Function GetIndex(ByVal SortExp As String) As Integer
Dim i As Integer = 0
For Each c As DataControlField In GridViewRequests.Columns
If c.SortExpression = SortExp Then
Return i
Else
i += 1
End If
Next
Return i
End Function
then updated my code for custom sorting the gridview to be as following :
1.Code for GridView Sorting Event
Protected Sub GridViewRequests_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GridViewRequests.Sorting
Dim t As DataTable = CType(FillDataSet().Tables(0), DataTable)
Dim dv As DataView = t.AsDataView
dv.Sort = e.SortExpression + " " + GetSortDirectionString(e.SortExpression)
GridViewRequests.DataSource = dv
GridViewRequests.DataBind()
If ViewState("SortDirection") = "ASC" Then
GridViewRequests.HeaderRow.Cells(GetIndex(e.SortExpression)).CssClass = "SortedAscendingHeaderStyle"
Else
GridViewRequests.HeaderRow.Cells(GetIndex(e.SortExpression)).CssClass = "SortedDescendingHeaderStyle"
End If
End Sub
2.Code For GetSortDirectionString Function
Private Function GetSortDirectionString(ByVal column As String) As String
Dim sortDirection = "ASC"
Dim sortExpression = TryCast(ViewState("SortExpression"), String)
If sortExpression IsNot Nothing Then
If sortExpression = column Then
Dim lastDirection = TryCast(ViewState("SortDirection"), String)
If lastDirection IsNot Nothing AndAlso lastDirection = "ASC" Then
sortDirection = "DESC"
End If
End If
End If
ViewState("SortDirection") = sortDirection
ViewState("SortExpression") = column
Return sortDirection
End Function
That It!!
thank for all who try to help me :D