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

hyperlink column

2 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Parnia
Top achievements
Rank 1
Parnia asked on 30 Oct 2012, 08:28 PM
hi.
I am using the rad Grid control  and it is bound to a datatable in code behind.
I want to change each cell to a hyperlink field at runtime and configure  NavigateUrl. When I'm clicking each row  a new page show. How can I do that?

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 31 Oct 2012, 05:32 AM
Hi,

Here is a sample  snippet to show the GridBoundColumn as a hyperlink.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        HyperLink link = new HyperLink();
        link.Text = item["UniqueName"].Text; //accessing the GridBoundColumn to get the text
        link.NavigateUrl = "Radgrid1.aspx";
        item["UniqueName"].Controls.Add(link);
    }
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        HyperLink link = new HyperLink();
        link.Text = item["UniqueName"].Text; //accessing the GridBoundColumn to get the text
        link.NavigateUrl = "Radgrid1.aspx";
        item["UniqueName"].Controls.Add(link);
    }
}

Thanks,
Shinu.
0
Parnia
Top achievements
Rank 1
answered on 31 Oct 2012, 05:44 AM
It's work.
thank you shinu :)
Tags
Grid
Asked by
Parnia
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Parnia
Top achievements
Rank 1
Share this question
or