|
-
Jan 24th, 2005, 06:44 AM
#1
Thread Starter
PowerPoster
hyperlink text color problem?
When i am trying to bind data to a datalist, one of the columns has a hyperlink - thats fine
but for some reason, there is no text!, or there is but it doesnt seem to appear on the hyperlink! The link exists, you can click on it fine but there is no text! I have even tried changing the forecolor but that didnt make a difference
if i put some text in the "text" databinder of that control/element - there is text, it shows it
but the hyperlink option doesnt...any ideas?
-
Jan 24th, 2005, 02:36 PM
#2
Frenzied Member
Re: hyperlink text color problem?
I had a problem like this with the DataGrid not allowing you to set a link color. I preform a loop in the DataBind event.
PHP Code:
private void dgProductsEx_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//add style tag to hyperlinks
if(e.Item.Controls.Count > 0)
{
for(int i = 0; i < e.Item.Controls.Count; i++)
{
if(e.Item.Controls[i].GetType().ToString() == "System.Web.UI.WebControls.TableCell")
{
if(e.Item.Controls.Count > 0)
{
for(int j = 0; j < e.Item.Controls[i].Controls.Count; j++)
{
if(e.Item.Controls[i].Controls[j].GetType().ToString() == "System.Web.UI.WebControls.HyperLink")
{
((System.Web.UI.WebControls.HyperLink)e.Item.Controls[i].Controls[j]).CssClass = "pkGridLink";
((System.Web.UI.WebControls.HyperLink)e.Item.Controls[i].Controls[j]).Attributes.Add("onmouseover", "status='PK Promotions ~ Custom Importing and Exporting.';return true;");
if(((System.Web.UI.WebControls.HyperLink)e.Item.Controls[i].Controls[j]).Text == "Edit")
{
string doEdit = e.Item.Cells[2].Controls[0].ClientID;
doEdit = doEdit.Replace("_", "$");
doEdit = doEdit.Replace("$$","$_");
((System.Web.UI.WebControls.HyperLink)e.Item.Controls[i].Controls[j]).NavigateUrl = "javascript:__doPostBack('" + doEdit + "','')";
}
else if(((System.Web.UI.WebControls.HyperLink)e.Item.Controls[i].Controls[j]).Text == "Delete")
{
string doDel = e.Item.Cells[3].Controls[0].ClientID;
doDel = doDel.Replace("_", "$");
doDel = doDel.Replace("$$","$_");
((System.Web.UI.WebControls.HyperLink)e.Item.Controls[i].Controls[j]).NavigateUrl = "javascript:__doPostBack('" + doDel + "','')";
}
else if(((System.Web.UI.WebControls.HyperLink)e.Item.Controls[i].Controls[j]).Text == "View Quotes")
{
string doQt = e.Item.Cells[5].Controls[0].ClientID;
doQt = doQt.Replace("_", "$");
doQt = doQt.Replace("$$","$_");
((System.Web.UI.WebControls.HyperLink)e.Item.Controls[i].Controls[j]).NavigateUrl = "javascript:__doPostBack('" + doQt + "','')";
}
}
}
}
}
}
}
}
I can't say I'm happy with it, but it does the job. The DataGrid is a DataList extended so you should be able to do something like this. I do some other things in there to wire up dummy links to a hidden Grid LinkButton because I could not make the thing take a style..... Which is stupid. Microsoft forgets things sometimes.....
Magiaus
If I helped give me some points.
-
Jan 24th, 2005, 03:07 PM
#3
Thread Starter
PowerPoster
Re: hyperlink text color problem?
lol i sorted the problem - forgot to put in the code in the text property of the databind for the hyperlink
-
Jan 24th, 2005, 03:09 PM
#4
Frenzied Member
Re: hyperlink text color problem?
Isn't that just way to much code to make a link look right.... lol
Magiaus
If I helped give me some points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|