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

How to make an already added column into a Hyperlink Column??

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Antonio
Top achievements
Rank 1
Antonio asked on 04 Aug 2011, 07:18 PM
Hi,

Very new to Telerik ctrls.

I have a RadGrid which is automatically generated from a datasource. I am not explicitly defining columns in the radgrid aspx.

How does one make one of those autocolumns into a Hyperlink Column in the code-behind (C#)?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Aug 2011, 07:16 AM
Hello Antonio,

Try the following method to achieve your scenario.
C#:
protected void RadGrid2_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
 {
     if (e.Item is GridDataItem)
     {
         GridDataItem item = e.Item as GridDataItem;
         TableCell tb = item["FirstName"];
         LinkButton lnk = new LinkButton();
         lnk.ID = "lnk";
         lnk.Text = "text";
         lnk.Attributes["href"] = "http://www.google.com";
         tb.Controls.Clear();
         tb.Controls.Add(lnk);
     }
 }

Thanks,
Shinu.
Tags
Grid
Asked by
Antonio
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or