Solved

Sorting Gridview Column that is htmldecoded

Posted on 2014-04-05
6
290 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
Comment Utility
The column header is empty
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
Why are you using HTMLDecode? What happens without it?
0
 

Author Comment

by:whiwex
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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 …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

7 Experts available now in Live!

Get 1:1 Help Now