Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-25-2006, 05:52 PM   PM User | #1
vinyl-junkie
$object->toCD-R(LP);


 
vinyl-junkie's Avatar
 
Join Date: Jun 2003
Posts: 3,054
Thanks: 2
Thanked 22 Times in 22 Posts
vinyl-junkie is on a distinguished road
Two database fields in one datagrid column

I have a HyperlinkColumn that right now only displays one database field (Artist) on my web page but I would like for it to display two database fields (The and Artist). I have found documentation for formatting a single field, but I can't find anything that will take in two fields. Is this even possible? If so, could you post some sample code for how to do that.

Here is the code I'm using right now:

Code:
<asp:HyperLinkColumn 
   DataNavigateUrlField="ArtistID"
   DataNavigateUrlFormatString="MusicDBSearch.aspx?ArtistID={0}"
   DataTextField="Artist" HeaderText="Artist"
   ItemStyle-Width="38%">
   <HeaderStyle CssClass="row2left"></HeaderStyle>
</asp:HyperLinkColumn>
So, for example, the link value currently says Corrs, and the link itself will be:
MusicDBSearch.aspx?ArtistID=74.

What I would like for the link value to say is The Corrs, but I only want the The database field to be displayed if it's populated. Does that make sense?

FWIW, I did find some documentation for ASP.NET 2.0 that would take in two fields for the URL of the HyperlinkColumn, but apparently you can't do the same thing on the HeaderTextField. I'm still using ASP.NET 1.1 but will soon be on 2.0, if that makes any difference.

In any event, whatever help you can provide would be appreciated.
__________________
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
SNAP to it!
vinyl-junkie is offline   Reply With Quote
Old 02-26-2006, 07:36 AM   PM User | #2
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
Just to see if i'm on the right track, so correct me if i'm wrong. You want to display a field in your database called "the", or you want to display the text "the"?

Either way, have you looked into using template columns?

Good luck;
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 02-27-2006, 02:07 AM   PM User | #3
vinyl-junkie
$object->toCD-R(LP);


 
vinyl-junkie's Avatar
 
Join Date: Jun 2003
Posts: 3,054
Thanks: 2
Thanked 22 Times in 22 Posts
vinyl-junkie is on a distinguished road
Quote:
Originally Posted by Brandoe85
Just to see if i'm on the right track, so correct me if i'm wrong. You want to display a field in your database called "the", or you want to display the text "the"?
I want to display a field in my database called "the"

Quote:
Either way, have you looked into using template columns?
Not until you mentioned it. I'm still pretty new to .NET.

Well, I converted it to a template column in Visual Studio, and here's what I came up with, which by the way, works like a charm. Thanks for the help!

Code:
<asp:TemplateColumn HeaderText="Artist">
    <HeaderStyle CssClass="row2left"></HeaderStyle>
    <ItemTemplate>
	<asp:HyperLink runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.The", "{0}") & " " & DataBinder.Eval(Container, "DataItem.Artist", "{0}") %>' NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.ArtistID", "MusicDBSearch.aspx?ArtistID={0}") %>'>
	</asp:HyperLink>
    </ItemTemplate>
</asp:TemplateColumn>
__________________
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
SNAP to it!
vinyl-junkie is offline   Reply With Quote
Old 02-27-2006, 03:27 AM   PM User | #4
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
Glad to hear you got it!
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:55 PM.


Advertisement
Log in to turn off these ads.