Solved

Sorting Gridview Column that is htmldecoded

Posted on 2014-04-05
6
292 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL syntax in VB.net 5 39
VB 2005 how to get a new line of data each time I try to write to a file. 10 24
VB.Net - KeyPress Event 4 36
Footer for each row on Gridview 2 21
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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 Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

785 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