Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
i have a database , on that i have SeeAlsoPageReference column, i saved value on that with the below code:

C#
String PageRefs = txt_SeeAlsoPageReference.Text;

                if (PageRefs.Contains(";"))
                {
                    String[] PageRefArray = PageRefs.Split(';');
                    for (int i = 0; i < PageRefArray.Length; i++)
                    {

                        seeAllpagereference += PageRefArray[i] + "<br/>";

                    }
                    
                }


i save the value in the database like:

ef35988c-9a70-493d-a98a-0320989b1a42
ef35988c-9a70-493d-a98a-0320989b1a42


aspx:
XML
<div id="SeeAlsoDiv">
           <asp:Label ID="lbl_SeeAlso" runat="server" Text="See Also" CssClass="lbl_seeAlso"></asp:Label><br />

           <asp:HyperLink ID="hyplnk_SeeAlso" href="" runat="server" Text=""></asp:HyperLink>
       </div>



i used the code:

C#
DataTable dt3 = DAL.OnlineHelp.PiiloHelp(Session["pageRef"].ToString(), Session["LanguageId"].ToInt32());
                if (dt3.Rows.Count > 0)
                {

                    string SeeAlsoPageRef = dt3.Rows[0]["SeeAlsoPageReference"].ToString();
                    SeeAlsoPageRef = dt3.Rows[0]["SeeAlsoPageReference"].ToString().Replace("&lt;", "<");
                    SeeAlsoPageRef = dt3.Rows[0]["SeeAlsoPageReference"].ToString().Replace("&gt;", ">");
                    hyplnk_SeeAlso.Text = SeeAlsoPageRef;

                }
with the above code it shows both the value but with 1 link.

i want when i retreive this value from database like:

ef35988c-9a70-493d-a98a-0320989b1a42

9487fe04-01e0-02cd-079f-c6be42224537

and both act as a different hyperlink, so when i click on the 1st link it goes a/c to that link,
and when i click on the second link it goes on another link.

db column may contain more than 2 values.

this is my first post in code project. please tell how i do this.
Posted
Updated 11-Mar-13 10:22am
v2

1 solution

You need 2+ Hyperlink objects, not just 1. A hyperlink only has one link (NavigateUrl) to one place, so if you need multiple links you need multiple hyperlinks, and split the data between them.

You could create a ListView for this field with multiple values. It would have a TemplateColumn which contained a Hyperlink.

Something along the lines of this:

XML
<asp:TemplateColumn>
            <ItemTemplate>
              <asp:HyperLink runat="server" ID="hyplnk_SeeAlso" NavigateUrl='<% BindingExpressionGoesHere %>' Text='<% BindingExpressionGoesHere %>'></asp:HyperLink>
            </ItemTemplate>
</asp:TemplateColumn>


Hope that helps.
 
Share this answer
 
Comments
Sampath Sridhar 11-Mar-13 23:36pm    
This should work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900