I have a usercontrol in an asp web forms application that I am working on in C#.
I am binding to a repeater and outputting a field of information, named “Text”, using the following syntax:
<%# DataBinder.Eval(Container.DataItem, "Text") %>
I am looking for a method that will allow my to search for a keyword within the string that is returned from above, and replace that string with a hyperlink such as
<a href="www.anysite.com/keyword">keyword</a>.
I’m not very familiar with user controls and getting data back in this manner so I am looking for advice on how this might be best handled.
Thanks!
Hook into the Repeater’s OnItemDataBound event.
The example on the linked documentation page does almost exactly what you want to do – it finds a label control in the item and updates the text. You should be able to modify it from there to do a string find/replace.