| | |
Data Grid: How to include Hyperlinks
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
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
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...
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
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
![]() |
Similar Threads
- data grid.... very urgent...... (C#)
- Help with data grid please (VB.NET)
- How to store data in data grid to database by single mouse click in Asp.net (ASP.NET)
- Data Grid in Win32 C (C++)
- data grid problems...please help (VB.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: what does assemblyinfo.cs consists of
- Next Thread: How to control decimal poit
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class click commonfunctions compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownmenu dynamic edit embeddingactivexcontrol expose findcontrol flash flv formatdecimal forms formview gridview homeedition iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings rotatepage save search security serializesmo.table sessionvariables silverlight smartcard sql sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webdevelopment wizard xml youareanotmemberofthedebuggerusers





