8
May

Sorting Indicator In Gridview

   Posted by: admin   in .Net Emperor

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

This entry was posted on Thursday, May 8th, 2008 at 6:36 am and is filed under .Net Emperor. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2 comments so far

piyush
 1 

what a great code man it will help me lot and i will impress my boss ha ha ha

August 6th, 2008 at 7:30 am
 2 

hi
a7f90nve5q2wvcus
good luck

January 9th, 2009 at 7:38 am

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment