This is a migrated thread and some comments may be shown as answers.

Place a Hyperlink in the RadGrid Header

2 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Morgan
Top achievements
Rank 1
Morgan asked on 27 Jul 2012, 03:54 PM
Is there a way to place a hyperlink in the header column of a Radgrid View.

Some of my columns contain a multiple sets of abbreviations... What makes this worse is that each company (which is an attribute of the page) have different abbreviations. What I wanted to do was make a column header that can be clicked that does the sorting with a question mark on the end that hyperlinks to an information page that gives the specific information about the abbreviations.

I tried to do this similar to how it would be done with an ordinary gridview:
 <telerik:GridBoundColumn DataField="Availability" 
      FilterControlAltText="Filter Availability column" FilterControlWidth="20px" 
      HeaderText="Status<a href='~/Reports/CodeList.aspx?coid=<%#Session("CoID")%>&property=status' target='_blank'>?</a>"; 
      SortExpression="Availability" UniqueName="Availability">
</telerik:GridBoundColumn>

The error that I get is: 

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 
Parser Error Message: Telerik.Web.UI.GridColumnCollection must have items of type 'Telerik.Web.UI.GridColumn'. 'a' is of type 'System.Web.UI.HtmlControls.HtmlAnchor'.
 

Is there anyway to actually place a hyperlink in the column header?

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 30 Jul 2012, 06:53 AM
Hello,

One suggestion is that you can add the HyperLink in column header in the ItemCreated event dynamically. Here is the sample code.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
 if (e.Item is GridHeaderItem)
 {
  GridHeaderItem item = (GridHeaderItem)e.Item;
  HtmlAnchor a = new HtmlAnchor();
  a.InnerText = "text";
  a.HRef = "/Reports/CodeList.aspx?coid=<%#Session("CoID")";
  item["Availability"].Controls.Add(a);
 }
}

Thanks,
Shinu.
0
Morgan
Top achievements
Rank 1
answered on 30 Jul 2012, 01:51 PM
I was really hoping to be able to do it in the markup rather than creating it, then adjusting the grid, but I guess I will just have to do it this way. Thanks so much.
Tags
Grid
Asked by
Morgan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Morgan
Top achievements
Rank 1
Share this question
or