473,785 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView coloring on client side

Hi, All!

I need to accomplish such functionality:
A data row should be highlighted with the other color if cursor is over it.

I also have the old code from asp which uses
<tr onmouseover="co lorrow(this,'#E EEEEE');"
onmouseout="col orrow(this,'#FF FFFF');">

for every row of a table.

What can I do to achieve the same for GridView or may be I should use
something else?

Thanks

--
Regards,
Inna Stetsyak aka InK_
Apr 15 '06 #1
6 1367
Hi,

you can do it in RowCreated event of GridView by adding those as attributes
to the row

Something like (the code is untested)

Protected Sub grid1_RowCreate d(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Grid ViewRowEventArg s) Handles grid1.RowCreate d
If e.Row.RowState = DataControlRowS tate.Alternate OrElse
e.Row.RowState = DataControlRowS tate.Normal Then
e.Row.Attribute s("onmouseover" ) = "colorrow(this, '#EEEEEE');"
e.Row.Attribute s("onmouseout ") = "colorrow(this, '#FFFFFF');"
End If
End Sub

(or just check RowType for being a DataRow and do it in RowDataBound)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"InK_" <in**@ukrpost.n et> wrote in message
news:OS******** ******@TK2MSFTN GP05.phx.gbl...
Hi, All!

I need to accomplish such functionality:
A data row should be highlighted with the other color if cursor is over
it.

I also have the old code from asp which uses
<tr onmouseover="co lorrow(this,'#E EEEEE');"
onmouseout="col orrow(this,'#FF FFFF');">

for every row of a table.

What can I do to achieve the same for GridView or may be I should use
something else?

Thanks

--
Regards,
Inna Stetsyak aka InK_

Apr 15 '06 #2
//In the itemDataBound Event for the DataGrid

For Each TableCell As TableCell In e.Item.Cells
TableCell.Attri butes.Add("onmo useOver", "go(this,'red') ;")
TableCell.Attri butes.Add("onmo useOut", "go(this,'white ');")
Next
//Then just add the javascript function in the html

function go( item , col)
{
item.style.back groundColor=col ;
}

HTH

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
"InK_" <in**@ukrpost.n et> wrote in message
news:OS******** ******@TK2MSFTN GP05.phx.gbl...
Hi, All!

I need to accomplish such functionality:
A data row should be highlighted with the other color if cursor is over
it.

I also have the old code from asp which uses
<tr onmouseover="co lorrow(this,'#E EEEEE');"
onmouseout="col orrow(this,'#FF FFFF');">

for every row of a table.

What can I do to achieve the same for GridView or may be I should use
something else?

Thanks

--
Regards,
Inna Stetsyak aka InK_

Apr 15 '06 #3
Thanks a lot for help.
It works now.

--
Regards,
Inna Stetsyak aka InK_

"Teemu Keiski" <jo****@aspalli ance.com> wrote in message
news:eA******** ******@TK2MSFTN GP04.phx.gbl...
Hi,

you can do it in RowCreated event of GridView by adding those as attributes to the row

Something like (the code is untested)

Protected Sub grid1_RowCreate d(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Grid ViewRowEventArg s) Handles grid1.RowCreate d
If e.Row.RowState = DataControlRowS tate.Alternate OrElse
e.Row.RowState = DataControlRowS tate.Normal Then
e.Row.Attribute s("onmouseover" ) = "colorrow(this, '#EEEEEE');"
e.Row.Attribute s("onmouseout ") = "colorrow(this, '#FFFFFF');"
End If
End Sub

(or just check RowType for being a DataRow and do it in RowDataBound)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"InK_" <in**@ukrpost.n et> wrote in message
news:OS******** ******@TK2MSFTN GP05.phx.gbl...
Hi, All!

I need to accomplish such functionality:
A data row should be highlighted with the other color if cursor is over
it.

I also have the old code from asp which uses
<tr onmouseover="co lorrow(this,'#E EEEEE');"
onmouseout="col orrow(this,'#FF FFFF');">

for every row of a table.

What can I do to achieve the same for GridView or may be I should use
something else?

Thanks

--
Regards,
Inna Stetsyak aka InK_



Apr 15 '06 #4
Thanks for help.
For sure it will work with DataGrid but I needed the same for GridView.
Look at the solution proposed by Teemu Keiski's. It works for me:).

--
Regards,
Inna Stetsyak aka InK_

"OHM ( One Handed Man )" <me@mine.com> wrote in message
news:uj******** ******@TK2MSFTN GP05.phx.gbl...
//In the itemDataBound Event for the DataGrid

For Each TableCell As TableCell In e.Item.Cells
TableCell.Attri butes.Add("onmo useOver", "go(this,'red') ;")
TableCell.Attri butes.Add("onmo useOut", "go(this,'white ');")
Next
//Then just add the javascript function in the html

function go( item , col)
{
item.style.back groundColor=col ;
}

HTH

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
"InK_" <in**@ukrpost.n et> wrote in message
news:OS******** ******@TK2MSFTN GP05.phx.gbl...
Hi, All!

I need to accomplish such functionality:
A data row should be highlighted with the other color if cursor is over
it.

I also have the old code from asp which uses
<tr onmouseover="co lorrow(this,'#E EEEEE');"
onmouseout="col orrow(this,'#FF FFFF');">

for every row of a table.

What can I do to achieve the same for GridView or may be I should use
something else?

Thanks

--
Regards,
Inna Stetsyak aka InK_



Apr 15 '06 #5
The principal is the same. Its only the event names which are different and
I dont need to look at Teemu's example as it's not me that needs the help.

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
"InK_" <in**@ukrpost.n et> wrote in message
news:uI******** ******@TK2MSFTN GP02.phx.gbl...
Thanks for help.
For sure it will work with DataGrid but I needed the same for GridView.
Look at the solution proposed by Teemu Keiski's. It works for me:).

--
Regards,
Inna Stetsyak aka InK_

"OHM ( One Handed Man )" <me@mine.com> wrote in message
news:uj******** ******@TK2MSFTN GP05.phx.gbl...
//In the itemDataBound Event for the DataGrid

For Each TableCell As TableCell In e.Item.Cells
TableCell.Attri butes.Add("onmo useOver", "go(this,'red') ;")
TableCell.Attri butes.Add("onmo useOut", "go(this,'white ');")
Next
//Then just add the javascript function in the html

function go( item , col)
{
item.style.back groundColor=col ;
}

HTH

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
"InK_" <in**@ukrpost.n et> wrote in message
news:OS******** ******@TK2MSFTN GP05.phx.gbl...
> Hi, All!
>
> I need to accomplish such functionality:
> A data row should be highlighted with the other color if cursor is over
> it.
>
> I also have the old code from asp which uses
> <tr onmouseover="co lorrow(this,'#E EEEEE');"
> onmouseout="col orrow(this,'#FF FFFF');">
>
> for every row of a table.
>
> What can I do to achieve the same for GridView or may be I should use
> something else?
>
> Thanks
>
> --
> Regards,
> Inna Stetsyak aka InK_
>
>



Apr 15 '06 #6
Sure, just FYI

--
Regards,
Inna Stetsyak aka InK_

"OHM ( One Handed Man )" <me@mine.com> wrote in message
news:uy******** *****@TK2MSFTNG P05.phx.gbl...
The principal is the same. Its only the event names which are different and I dont need to look at Teemu's example as it's not me that needs the help.

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
"InK_" <in**@ukrpost.n et> wrote in message
news:uI******** ******@TK2MSFTN GP02.phx.gbl...
Thanks for help.
For sure it will work with DataGrid but I needed the same for GridView.
Look at the solution proposed by Teemu Keiski's. It works for me:).

--
Regards,
Inna Stetsyak aka InK_

"OHM ( One Handed Man )" <me@mine.com> wrote in message
news:uj******** ******@TK2MSFTN GP05.phx.gbl...
//In the itemDataBound Event for the DataGrid

For Each TableCell As TableCell In e.Item.Cells
TableCell.Attri butes.Add("onmo useOver", "go(this,'red') ;")
TableCell.Attri butes.Add("onmo useOut", "go(this,'white ');")
Next
//Then just add the javascript function in the html

function go( item , col)
{
item.style.back groundColor=col ;
}

HTH

--
( OHM ) - One Handed Man
AKA Terry Burns - http://TrainingOn.net
"InK_" <in**@ukrpost.n et> wrote in message
news:OS******** ******@TK2MSFTN GP05.phx.gbl...
> Hi, All!
>
> I need to accomplish such functionality:
> A data row should be highlighted with the other color if cursor is over > it.
>
> I also have the old code from asp which uses
> <tr onmouseover="co lorrow(this,'#E EEEEE');"
> onmouseout="col orrow(this,'#FF FFFF');">
>
> for every row of a table.
>
> What can I do to achieve the same for GridView or may be I should use
> something else?
>
> Thanks
>
> --
> Regards,
> Inna Stetsyak aka InK_
>
>




Apr 15 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1220
by: NH | last post by:
I know how to make client side paging work in the gridiew control using a sqlDataSource (and it works great!). But how can I "code" this i.e. I want to use a dataset as the datasource of the gridview. I have a stored procedure that returns data based on what parameter is passed in to it from the page load event of an asp.net form and then I want to bind the gridview to this dataset. But how can I use client cide paging in this context? ...
4
1815
by: Chris | last post by:
Hi, I read about client callback and i have a question. Assume the option "sorting" is set in a gridview. Each time the user clicks on a fieldname, the data are sorted. My question is: are the data on each click fetched from the server, or are they 'cached' on the client-side and so avoiding a lot of transferts between server and browser? If not 'cached', would it not bebetter to use the client callback
2
309
by: moshi | last post by:
Hi everyone, I have a gridView, and I give to one of it's boundColumns property of "visible=false". I don't want it to be shown in client side, but I want it's values to be recognized in server side. It is realy not shown in client side, but when I post-back, and asking about that column values, I get "" , like it is empty. (When it is "visible=true" it is fine - there are values in it). What can I do ? I know that one of the solutions...
1
3529
by: jmdolinger | last post by:
Hi all, I'm a newbie to Atlas (and recently ASP.NET) after coming from a long Java background, also have done quite a bit with an Ajax.NET/ASP.NET 1.1 project, but it was basically all javascript, nothing really having to do with ASP.NET... I'm attempting to put together an application that consists of several GridView controls each bound to some xml data. Each table exists in its own update panel. The two effects I'm going for are:
2
12159
by: NH | last post by:
I have a gridview with a delete button as follows... <ItemTemplate> <asp:ImageButton id="deleteAttachment" OnClientClick='return confirm("Are you sure you want to delete this Attachment?");' imageallign="absbottom" commandName="DeleteAttachment" tooltip="Delete this Attachment" imageurl="images/icons/delete.jpg" runat="server"></asp:ImageButton> </ItemTemplate>
4
4871
by: Tom | last post by:
I need to grab the text from a cell in my gridview and pass it in my querystring I need to do this on the client
0
2751
by: rupinderbatra | last post by:
Hi, I want to implement a client side filter box for a Gridview server control. I dont want to do it server side or AJAX based because the existing architecture does not allow that much flexibility. The only way I am looking at is implementing a client side filter box. In my case, the filter should only be applied to one particular column value rather than the entire gridview. If someone has done a similar implementation, please share...
4
8846
by: Peter | last post by:
I want to call a JavaScript on PageIndexChanged event, how do I do that? Thank You Peter
5
4244
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I am using <asp:Gridview> to display my data. I am adding columns and rows dynamically. I am facing following issues: 1. I want scrollbars around the gridview and for this purpose i used <div style="overflow:auto"> and its working fine. But issue is that the header row also scroll down with scrollbar and i want to fix header row . I searched on google and found a lot of solutions but nothing is working for me. I am using css for...
0
9484
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.