Highlighting GridView Row on MouseOver

Of late , i've  been receiving  E-Mails  asking for  publishing  the content  for BEGINNERS  in  .NET ,  So  i've decided  to  include  some  new posts  for  them .

 

In  this  article  , we'll  see  how  we  can  change  the  row color  of  a  GridView  when   anyone   moves  their mouse over  the GridView .  So  let's get it  started.

1) Create  a  page name Test.aspx

 

Test.aspx ( HTML Markup)

 <div class="TEST">
    <asp:GridView  ID="GV1" runat="server" >
        <Columns>
                  <asp:TemplateField>
                          <ItemTemplate>
  
                                 <asp:LinkButton ID="Link1"  runat="server" Text='<%# Eval("FirstName") %>' CommandName="LINK"   ></asp:LinkButton>
                         </ItemTemplate>
                  </asp:TemplateField>
       </Columns>
    </asp:GridView>
       
  </div>

 

Test.aspx.cs

protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            con = new SqlConnection("uid=sa;pwd=123456;database=Talib");
            con.Open();
            da = new SqlDataAdapter("select  * from tblRegistration order by id desc", con);
            ds = new DataSet();
            da.Fill(ds);
            GV1.DataSource = ds;  // GV1 is  the name of  GridView
            GV1.DataBind();
        }

        catch (Exception ex)
        {
            Response.Write(ex.Message);

        }
        finally
        {
            con.Close();
        }

    }

 

2)  Now  we  need to  assign  the  CSS  styling  for this   GridView  ,  illustrated  below

<style type="text/css">
        .TEST div table tr:hover
    {
          background-color:silver;
    }

</style>

 

Now, we're done.  Execute  the  page  and  see how  it  works.

 

 

I  hope you people like this post ,till  then  enjoy  Programming ......   Smile

 


Tags: , , , , ,
Categories: ASP.NET

8 Comments
Actions: E-mail | Permalink | Comment RSSRSS comment feed

Comments

October 31. 2009 06:32

fast cash loans

I just hope to have understood this the way it was meant

fast cash loans

October 31. 2009 10:18

Payday Loans

You never run out of ideas don't ya .. nice post Smile

Payday Loans

November 8. 2009 02:44

Talib Ali Khan

Thanks folks...

Talib Ali Khan

November 15. 2009 03:16

payday loans

thanks!  very helpful post!! like the template btw ;)

payday loans

November 24. 2009 14:00

Bakersfield Death Records

It appears that you have put a good amount of effort into your blog and this world require more of these on the Internet these days. The both of us actually enjoyed your post. I do not have a great deal to say in reply, I just wanted to sign up to reply well done.

Bakersfield Death Records

December 3. 2009 23:08

Acai Berry

Excellent post.This was actually what I was looking for, and I am glad that I finally came here! Thanks for sharing the such information with us.

Acai Berry

December 5. 2009 18:10

Talib Ali Khan

Glad to hear that Anjali .  *_*

Talib Ali Khan

January 5. 2010 01:37

WY Payday Loans

thanks!  very helpful post!! like the template btw ;)

WY Payday Loans

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading



 


© Copyright 2009. www.onlineasp.net All Rights Reserved.