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

Create a Hyperlink column on the 'Fly'

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 03 Nov 2008, 04:32 PM
Hi.. I have a hyperlink column.

 

<telerik:GridHyperLinkColumn DataTextField="Subject" HeaderText="Subject " UniqueName="Subject" />

 

I need to create the navurl on the fly when the data is bound.. But the hyperlink does not seem to work and is not enable. What is wrong with the following ?  Thanks

 

 

protected void RadGridCompleted_ItemDataBound(object sender, GridItemEventArgs e)

 

{

 

if (e.Item is GridDataItem)

 

{


 

 

HyperLink link = (HyperLink)dataBoundItem["Subject"].Controls[0];

 

link.ID =

"Subject";

 

 

QueryString qs = new QueryString();

 

qs[

"MESSAGEINDEX"] = dataBoundItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["MessageIndex"].ToString();

 

qs[

"CorrespondenceID"] = dataBoundItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["CorrespondenceID"].ToString();

 

link.NavigateUrl =

string.Format("ViewEmail.aspx?MessageIndex={0}&CorrespondenceID={1}&redirect=ProcessCompletedCorrespondence.aspx&reply=false", qs.ToString(), qs.ToString());

 

 

link.ForeColor = System.Drawing.

Color.Black;

 

link.Font.Underline =

false;

 

 

 





}
}

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Nov 2008, 04:47 AM
Hello Jon,

I tried the following code at my end to set the NavigateUrl for a hyperlink and its working fine. I couldnt find how you were accessing the grid row in the code you provided.
cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem dataBoundItem = (GridDataItem)e.Item; 
            HyperLink hyplnk = (HyperLink)dataBoundItem["Subject"].Controls[0]; 
            hyplnk.NavigateUrl = "Default2.aspx"
 
        } 
    }

Thanks
Princy.
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or