Solved

Sorting Gridview Column that is htmldecoded

Posted on 2014-04-05
6
291 Views
Last Modified: 2014-06-12
I have a gridview in vb.net. In the rowdatabound event I do a
e.Row.Cells(5).Text = Server.HtmlDecode(e.Row.Cells(5).Text)

After I do this I can't sort on that column. how do I get around this.
0
Comment
Question by:whiwex
  • 3
  • 2
6 Comments
 

Author Comment

by:whiwex
ID: 39980409
The column header is empty
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39981177
You need to check the row, to make sure that it is a data row.

GridView.RowDataBound Event
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound(v=vs.110).aspx

Sub CustomersGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)

    If e.Row.RowType = DataControlRowType.DataRow Then

      ' Display the company name in italics.
      e.Row.Cells(1).Text = "<i>" & e.Row.Cells(1).Text & "</i>"

    End If

  End Sub

Open in new window

0
 

Author Comment

by:whiwex
ID: 39981309
My problems is when I do the server.htmldecode in the heading I can't sort on that column If I use the code below I lose the ability to sort on column 4.

Protected Sub gvFamiliesUnderQuota_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvFamiliesUnderQuota.RowDataBound

          If e.Row.RowType = DataControlRowType.Header Then          
            e.Row.Cells(4).Text = "Fundraising<br/>Profit"
            e.Row.Cells(4).Text = Server.HtmlDecode(e.Row.Cells(4).Text)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39982639
Why are you using HTMLDecode? What happens without it?
0
 

Author Comment

by:whiwex
ID: 39987006
I am using it because I want the heading to look like this
Fundraising
    Profit
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 40026944
You can customize the header column and add a custom image for sorting.

Example here

http://zc0000.wordpress.com/2007/10/09/customize-gridviews-header-for-sorting-function/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now