Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hyperlinking Values from a Database

Status
Not open for further replies.

djs45uk

Technical User
Nov 7, 2004
103
GB
Hello

Forgive me for asking so many questions...I'm trying very hard to learn this...and I'm very grateful for your help.

I would like to retrieve some values from a database like this:

Code:
SELECT [linkTitle], [linkURL] FROM [Links] WHERE ([linkCategory] = @linkCategory)

and display them in a table (GridView would be fine) as a list of all the linkTitle fields. Each linkTitle field will be a hyperlink which uses linkURL as its destination.

Now I've done this many times in ASP and it's really very easy. Is there an easy way to do it in ASP .net that I'm missing.

Any help would be much appreciated

Daniel
 
if your wonder on the aspx side, this should give u an idea, if it on the coding side, post back with more details, ie, where you are stuck at. Code from u will help us help u!

Code:
<asp:DataGrid ID="fileDG" runat="server" AutoGenerateColumns="false" BorderColor="0"
    CellSpacing="1" GridLines="None" CssClass="dg" DataKeyField="fileID">
    <HeaderStyle BackColor="#5B84AF" CssClass="dgHead" />
    <AlternatingItemStyle BackColor="#FFFFFF" />
    <ItemStyle BackColor="#DEDFDE" />
    <Columns>
        <asp:TemplateColumn HeaderText="Attached Files" ItemStyle-VerticalAlign="top">
            <ItemTemplate>
                <asp:HyperLink ID="Hyperlink1" ToolTip='<%# DataBinder.Eval(Container.DataItem, "fileDate") %>'
                    runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "fileName") %>'
                    NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "helpPath") %>' Target="_blank"
                    CssClass="hyper" />
            </ItemTemplate>
        </asp:TemplateColumn>
    </Columns>
</asp:DataGrid>
 
Thank you both!

That tutorial is great Tperri - it has answered another of my problems which was how you combine columns in gridview. I'll def be adding that to my favourites.

Adamroof - the code looks great - I'll give it a go in a mo.

Thank you very much again

Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top