Some Clients Need That When In Grid view Sorting Oration Will Perform we Can`t Get That what will be Doing in Grid. Also Clients Said that in Which Direction Our Sorting is Currently available that is also not know please do some thing. So Here is the answer Please Paste this Simple Code in Your .Aspx.vb File and Get Sorting Indicator When you Do Sorting.
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If Not (e.Row Is Nothing) AndAlso e.Row.RowType = DataControlRowType.Header Then
For Each cell As TableCell In e.Row.Cells
If cell.HasControls Then
Dim button As LinkButton = DirectCast(cell.Controls(0), LinkButton)
If Not (button Is Nothing) Then
Dim image As Image = New Image
image.ImageUrl = “images/default.gif”
If GridView1.SortExpression = button.CommandArgument Then
If GridView1.SortDirection = SortDirection.Ascending Then
image.ImageUrl = “images/uparrow.jpg”
Else
image.ImageUrl = “images/downarrow.jpg”
End If
End If
cell.Controls.Add(image)
End If
End If
Next
End If
End Sub
After placing this Code you Will Insert One Folder In Your Application Name is “images” and Insert 3 Images One For Default , One For Uparrow and Last One For Downarrow.
Enjoy Code. Impress Your Boss
Hello ! I am Arjun Jadeja a Software Engineer by Profession. You can contribute and I will distribute your ideas through this site. Thanks and Enjoy
2 comments so far
Leave a reply