Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sorting Gridview Column that is htmldecoded

Posted on 2014-04-05
6
293 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 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