Link to home
Create AccountLog in
Avatar of JoshinHtown
JoshinHtownFlag for United States of America

asked on

Create Hyperlink in DetailsView..

Hello-

I have a DetailsView that gets binded to a datatable.  One of the Columns has a Website URL called "Website".  Another Column has a ID field that needs to get binded to the Website URL address and that field is called "HCAD_NUM".  I need a hyperlink to appear at runtime that the user can click on and the Webpage will popup.  Below is the only code I have at this point.

Thanks,
<asp:Panel ID="Panel1" runat="server" Height="552px" Width="296px" ScrollBars="Auto">
            <asp:DetailsView ID="DetailsView1" runat="server" BackColor="#CCCCCC" BorderColor="#999999"
                BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black"
                Height="50px" Width="125px">
 
                <FooterStyle BackColor="#CCCCCC" />
                <RowStyle BackColor="White" />
                <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
 
            </asp:DetailsView>
        </asp:Panel>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jmwheeler
jmwheeler

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of JoshinHtown

ASKER

Yes almost perfect.  After they click the hyperlink, can it open the webpage in a new window and not the same window that the detailsview is displayed in?
Also, one last thing.  You will notice in the screenshot below the hyperlink is showing the full URL of website.  Can it just display the words "Website Link" and have the hyperlink work off of that?  Also, any chance this link can show up at top of DetailsView?

That would be all I need.  Thank you so much if you can get this working.

Best regards,
Display-of-detailsView.gif
Avatar of jmwheeler
jmwheeler

The adjustment below will change the diplay text and open it in a new window:

<a href='<%# Eval("Website") %>?ID=<%# Eval("HCAD_NUM") % target="_blank">'Website Link</a>

If you want to re-order the field you would need to set "AutoGenerateRows" to false on your details view and then specify the fields you want in the fields tag I used in my example above.
Hi jmwheeler-

I apologize for getting a tad impatient but I posted another Question at the below link related to this matter.  I gave you points for this thread but I felt the other questions which you have recently answered should be a seperate question.  Please post a thread at the below link to get the points there as well.  Thanks jmwheeler

https://www.experts-exchange.com/questions/24190566/Customize-Display-of-DetailsView.html