Results 1 to 4 of 4

Thread: hyperlink text color problem?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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?

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    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 senderSystem.Web.UI.WebControls.DataGridItemEventArgs e)
            {
                
    //add style tag to hyperlinks
                
    if(e.Item.Controls.Count 0)
                {
                    for(
    int i 0e.Item.Controls.Counti++)
                    {
                        if(
    e.Item.Controls[i].GetType().ToString() == "System.Web.UI.WebControls.TableCell")
                        {
                            if(
    e.Item.Controls.Count 0)
                            {
                                for(
    int j 0e.Item.Controls[i].Controls.Countj++)
                                {
                                    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.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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

  4. #4
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    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
  •  



Click Here to Expand Forum to Full Width