Changing hyperlink style in the datagrid using CSS

Posted on 2004-10-21
Last Modified: 2012-08-13
I want to change the header hyperlink which is automatically created as i have enable sorting in the datagrid. the problem is that default hyperlink of css class has been applied to the header links of datagrid and i dont want that. I need to change the style.... here is the code

<asp:BoundColumn DataField="NAME" SortExpression="Name" HeaderText="Student Name"></asp:BoundColumn>

the Student Name is the hyperlink on the header of the datagrid and i need to change its style. Plesase give me the css class and where to apply that class to change the header hyperlink .

Also i have enabled paging in the datagrid... and below pages hyperlink are show 1 2 3 4 5 ... and hyperlinks again in default colors... and i dont want that... please do let me know how to change that also... actually the problem is to change the hyperlink styles in the datagrid in short.

Thanks and Regards
Question by:faruquis
    LVL 28

    Expert Comment

    Hi faruquis,

    use this

                <asp:BoundColumn DataField="NAME" SortExpression="Name" HeaderText="Student Name">

                   <HeaderStyle CssClass="Your css class name">

                   <FooterStyle CssClass="Your css class name">



    Author Comment

    no sir.. it isnt working... my class name is datagridlinks and i aplied the class as told by you... the generated code is this... and the class is not applied to the <a href...... take a look

    <td class="datagridlinks"><a href="javascript:__doPostBack('reportData$_ctl2$_ctl0','')">Student Name</a></td><td>
    LVL 28

    Expert Comment

    you have to declared the class like this
    .LNnTxt1 { FONT-SIZE: 11px; COLOR: #000099; FONT-FAMILY: arial, verdana, helvetica, sans-serif; }
    A.LNnTxt1:link {       FONT-SIZE: 11px; COLOR: #000099; FONT-FAMILY: arial, verdana, helvetica, sans-serif;}
    A.LNnTxt1:visited {      FONT-SIZE: 11px; COLOR: #000000; FONT-FAMILY: arial, verdana, helvetica, sans-serif; }
    A.LNnTxt1:active {      COLOR: #ff0000; }
    A.LNnTxt1:hover {      COLOR: #990000; TEXT-DECORATION: none; }

    and then add LNnTxt1 as a class name to the header/footerstyle


    Author Comment

    this is not a valid answer.. have been able to find a valid solution and implementted that also.. thanks for you time buddy.. here is the solution

    Accepted Solution

    PAQed with points refunded (50)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now