views:

33

answers:

2

I have a situation where I currently have a HyperLinkColumn control that I would like to modify to have a Label or simple text appear in the same column as the hyperlink. How do I acheive this please? Any Idea?

+1  A: 

If this is DataGrid then you can handle the ItemCreated event and add code that adds a new control. For example:

<asp:DataGrid ... OnItemCreated="OnMyDataGridItemCreated" ... />

private void OnMyDataGridItemCreated(object sender, DataGridItemEventArgs e) {
    Label textLabel = new Label();
    textLabel.Text = "Hello!";
    e.Item.Cells[3].Controls.Add(textLabel);
    // Instead of "3" you might need to pick a different column
}
Eilon
Say I want to Add the Label and then databind it to display information that the HyperlinkColumn also displays. How would I go about doing that please?
Kobojunkie
A: 

If you are using a GridView you could use a TemplateField. In there, you can have a hyperlink and a label, which are both databound. In the OnRowDataBound() Event you can decide which of the two controls should be visible to the user.

citronas