i have a list of URLS and titles
i want to show them just like as display in google search results
i have this code
<asp:Repeater id="repLinks" runat="server">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Container.DataItem.ToString() %>' Text="LinkText" />
</ItemTemplate>
</asp:Repeater>
and i have a list
ist<string> lLinks = new List<string>();
lLinks.Add(link.InnerText.Trim());
lLinks.Add(hrefValue.Replace("/url?q=", ""));
repLinks.DataSource = lLinks;
repLinks.DataBind();
i want to change the code to show the titles which is in
link.InnerText.Trim()
for each url not the constant text in Text="LinkText"
any body can help me plz?
Unless I've misunderstood, you want to set the Text property to the same value as the NavigateUrl property. If so, you do the same as you already did...
Text='<%# Container.DataItem.ToString() %>'
If you meant something else, please explain more, as it looks like you're dealing with a plain string, so you've only got the one option.
Edit based on your comment, it looks like you want to use two separate strings in the tag. If so, you'd be better off creating a simple class with two string properties...
public class LinkData {
public string Url { get; set; }
public string DisplayText { get; set; }
}
...and using a collection of these for your data source. You could create the class, and set the two properties in your code behind, then just use the property names in your view code...
Text='<%# Container.DataItem.DisplayText %>'