RSS Forums RSS
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 5625 | Replies: 2 | Solved
Reply
Join Date: Aug 2005
Posts: 3
Reputation: Madhusudhan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Madhusudhan Madhusudhan is offline Offline
Newbie Poster

Data Grid: How to include Hyperlinks

  #1  
Aug 4th, 2005
Hi all,
I have data grid:
In that i have to show different hyperlinks colors with type of memberships.
If gold member then Hyperlink is Green
If Silver member then Hyperlink is Red.
otherwise the Hyperlink shoudl be Blue !!!
How to achieve this is Data grid!!!.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Posts: 50
Reputation: SelArom is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 1
SelArom's Avatar
SelArom SelArom is offline Offline
Junior Poster in Training

Re: Data Grid: How to include Hyperlinks

  #2  
Aug 4th, 2005
try changing the column that has the hyperlink to a template column. then you can go into the (Databindings) property of the hyperlink and set the cssclass based on the type of membership.

For example, add these css classes to your css style sheet:

.gold a:link {color:green;}
.silver a:link {color: red;}
etc...

then you can either add a column to your data table to hold the type of membership or determine it programatically.

for example you can put this in the databinding for the hyperlink:
DataBinder.Eval(Container, "DataItem.memberType")

hope that made sense and helped!

-SelArom
You are somebody, just as I am somebody... but in the end, when you REALLY think about it, we are all nobody...
Reply With Quote  
Join Date: Jul 2005
Location: Kansas City, Missouri
Posts: 17
Reputation: cambia is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 3
cambia's Avatar
cambia cambia is offline Offline
Newbie Poster

Re: Data Grid: How to include Hyperlinks

  #3  
Aug 11th, 2005
Hi Madhusudhan,

Your question inspired me to write some in-depth articles on the subject. :eek:

I have dealt with this same problem before. I ultimately created several custom template columns which satisfy most needs.

Adding Simple Columns to DataGrid (BoundColumn and HyperLinkColumn)

A Custom HyperLink Column Example Which Inherits from TemplateColumn

As I demonstrate in the second article you basically have two choices:

1) Perform some preprocessing on your DataTable after filling it from the database and before binding it to the DataGrid. For example, create another column, loop over all the rows and fill the added column with the HTML you want to display. Then you can bind that column to a simple BoundColumn on the Grid.

2) Use TemplateColumns where you have total control. Then once you define your DataGrid columns, there is no preprocessing of your DataTable required. You can bind the table directly to the grid after reading from the database.

If you need a quick and dirty solution, use 1), if you expect to run into this problem again, use 2).

For all the details and my custom link template column, check out the articles.

Cheers,
- Steve
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 5:00 am.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC