Solved

Sorting Gridview Column that is htmldecoded

Posted on 2014-04-05
6
294 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
[X]
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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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