Link to home
Start Free TrialLog in
Avatar of russomr
russomr

asked on

Add a hyperlink to a data view control

I have the following:

<asp:GridView ID="gvResults" runat="server" Width="100%" AutoGenerateColumns="false" CellPadding="4" ForeColor="#333333"
    GridLines="None">
    <Columns>
        <asp:BoundField ReadOnly="true" HeaderText="DBA Name" DataField="DBAName" />
        <asp:BoundField ReadOnly="true" HeaderText="City" DataField="City" />
        <asp:BoundField ReadOnly="true" HeaderText="State" DataField="State" />
        <asp:BoundField ReadOnly="true" HeaderText="P&C Volume" DataField="PCVolume" />
        <asp:BoundField ReadOnly="true" HeaderText="Life Vol" DataField="LifeVolume" />
        <asp:BoundField ReadOnly="true" HeaderText="Field Rep" DataField="PCFieldRep" />
    </Columns>
</asp:GridView>

I get a view with all of the fields displaying correctly, but for the DBAName, I actually want to display the DBAName, but have it be a hyperlink that opens a new window with the URL (which is contained in the datasource as 'Website').  If 'Website' is null or empty, it does not show the DBAName as a hyplerlink, but just text.

Can anyone help?  This is my first exposure to a dataview.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of strickdd
strickdd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of russomr
russomr

ASKER

That works, but how do I get it to not be a hyperlink if there is no value in the website field?  Where and how do I place the logic?
You can do an onDataBinding event and manipulate the data going in if you need to.
Avatar of russomr

ASKER

How do you do that?  I've upped the points because I feel I'm asking a lot.