Selecting a gridview row and keeping the last selected row in a gridview highlighted after mouse moves over a new row.

What is the best way to show a gridview row highlighted once selected and keep it highlighted once the mouse moves over a different row?



6/10/2008 2:30:32 PM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 58


you can use

<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="#FFFFFF" />

plz let me know if i misunderstood you

6/10/2008 5:00:37 PM

Thanks for your help. One problem; however, is that after the row has been selected and I check the "grid.SelectedIndex" it has a value of -1 and not the index of the row that was selected on the grid. What do you recommend?



6/10/2008 5:52:45 PM


sorry i dint get your question.

if you want to know the selected row you can try


6/10/2008 9:24:43 PM

Add this code in Page_load event

Dim MyStringBuilder As New System.Text.StringBuilder

    MyStringBuilder.Append("var oldgridSelectedColor;")
    MyStringBuilder.Append("  function setMouseOverColor(element){")
    MyStringBuilder.Append("     oldgridSelectedColor =;")
    MyStringBuilder.Append("  function setMouseOutColor(element){")

    ClientScript.RegisterStartupScript(Me.GetType, "EnterHandler", MyStringBuilder.ToString)


Add this code in the GridView1_RowDataBound event

 If (e.Row.RowType = DataControlRowType.DataRow) Then
      e.Row.Attributes("onmouseover") = "javascript:setMouseOverColor(this);"
      e.Row.Attributes("onmouseout") = "javascript:setMouseOutColor(this);"

    End If


If this solve your issue please Mark this post as "Resolved"



If it solves your issue please mark this posting as "Answered".

6/10/2008 9:58:49 PM

Similar Artilces:

Gridview paging enabled. Has checkbox to select the row . If user select the checkbox on one page and move to 2nd page to select the rows there also to export the selected rows to excel. But doing so
HiI am using Gridview and that has paging enabled. Using checkbox to select the particular row of the gridview to export the selected rows to the excel . Everything is working fine except for one case.Let user selected the "check" box for, five rows which user would like to export to excel (two of rows on page 1 of results and 3 of them on page 2 of results), however it only exports the 3 row details from page 2, because it seems to de-select the 2 rows from page 1 when I move to page 2 and vice versa. The code i am using is as :protected void BtnExcel_Click(object sender, EventArg...

new row below selected row in gridview to display child gridview
Hello,   I have a gridview that up selected..shows the nested child grivdview. The problem I currently have is that it stuffs all the data into a column whcih blows the whole tbale out of whack. What I need to do is create a new row below the sleected row to house the new child grivdview. I have seen third party controls do this such as teleriks radgrid but I wont to do this with the gridview control.  Any articles on how to do this? Does AJAX support this? Any help is greatly appreciated.    ...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

Selecting the multiple rows in GridView and inserting the selected rows to another Gridview & Performing some operations on it
 Dear All, I have become mad for solving this problem. Please Help me. I have a Gridview bound to a datasource. I inserted the CheckBox Control in Templet to select certain rows. Gridview1 contains some products id & name.I want to insert the selected rows in to second Gridview  and in the second Gridview I need to add two more colums AdvicedQty & AcceptedQty(TextBox Cotrol).The user will select few products in Gridview1 & clicks add which will be added another gridview then in second Gridview he enters the AdviceQty & AcceptedQty.After entering the data he cli...

select multiple rows with its row highlighted in GridView
Hello everyone, I'm not using any checkbox or select command to select the row in the GridView, I use the "RowDataBound" event in the GridView for the "onmouseover" click and row select.  That works fine for me but I want to have the functionality to select a multiple rows with its row highlighted and have a row selected count. For example, If I select a row, it hightlights that row and if I select another row, it will do the same thing and have the previous row still highlighted.  I have been looking for a way to implement this but can't find a ...

Highlight selected row and unhighligh unselected row in gridview
I wanted the selected row to be highlighted when the user click on select link button on a gridview, so the code I have below works exactly that. However, when I click on a different row, the new row is now highlighed, but the hilighted stays with the previous row as well. Shouldn't the highligh be only on the seleted row? what am I doing wrong or not doing? any help would be really appreciated.protected void gridview1_RowCommand(object sender, GridViewCommandEventArgs e) {if (e.CommandName.Equals("Select")) {index = Convert.ToInt32(e.CommandArgument); GridViewR...

Using a row selection in a gridview to create database rows for another gridview
Hi there, I have 2 gridviews on a form, the first displays some template rows from a database table.  The second displays some user specific rows (with additional data added to the template info) from the same table. They both work fine for displaying the info.  Now what I want to do, is allow users to 'select' a template row on the first gridview, and have that action automatically: create a new user-specific row, with added fields from profile data etc. insert it into the table then refresh the second gridview in order to show the new added row. C...

Iwant to select a row and column in gridview with select radiobutton. but No checked change event.below put a button .if click that button to seleced row values will select
I want to select a row and column in gridview using radiobutton in gridview . if which radio button is select that row will select and i want that row column values in outside individual textboxes of next page.  but in that only single radiobutton will select and no post back="true" bcz iam not using checked change property. i inserted button below gridview. if i click the that selected row and columns values are stored into textboxes of next page im using this code .but im getting one column in that row. but i want all columns in that selected row so plz repla...

Insert row above selected row in GridView
Hi, I've been asked to create a list with an insert button at the end of each row that, when clicked, will insert a new line above the selected row and allow the user to enter in information.  It won't be an edit, but a new entry - however it needs to be displayed above the row with the "Insert" button.  I'm not sure if this is possible or not, but any help would be most appreciated. Thanks! Check this article my suggestion helps Regards,Vinz"Code, Beer and Music" that's my way of ...

selecting row in gridview by clicking anywhere in row (not just on 'select' link)
Hi there- I would like my gridview to behave such that a click anywhere in the (whole length of the) row would act just like clicking the "select" column link. Anyone have any code or suggestions?   You could use: ( but you would also need to disable event validation ) <%@ Page Language="VB" EnableEventValidation="false"%> Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then e.Row.Attributes.Add("onclick", "javascript:__doPostBack('GridView1','select$" &...

Problem in Using DropDownList Control to select a selected row of SqlDataSource that is under GridView Control
Hi all,In my SQL Server Management Studio Express, I have a database "ChemDatabase" that has a table "LabData"  formatted in the following way: SampleID int PRIMARY KEY, SampleName nvarchar(25), ChemicalName, nvarchar(25), Concentration decimal(6.2) with 5 rows of records in this .dbo table. In my Visual Web Developer Express, I created a website "RPD-TCE" for extracting a row of record from the LabData table by using a DropDownList, a GridView and a SqlDataSource.  I want to click DropDownList to list one number of S...

does anyone know how to do that, when I click the last row of the gridview, the gridview will automatically add an empty new row for me.
does anyone know how to do that, when I click the last row of the gridview, the gridview will automatically add an empty new row for me.   thanks hi there,the only I could think of for now is is enbale footer rowthen hide it onpageload so when last row click set footer.visible to true  ...

I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row.
 Hi, Let say I've 4 rows in a table. I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row. Thanks in advance Asghar Ali Mohammed Designer and Developer)Do not forget to "MARK AS ANSWER" on the post that helped you. If you can use Linq, you can use Skip., EdMicrosoft MVP - ASP/ASP.NET Hii dear..U can fire the Query select Top(3) from Table1 order by id desc.. "A conclusion is whe...

Select a row in GridView and show dependent Values in Other GridView on the basis of selection...
hi, i've a parent table which has many values in it.. i also have some child tables which contains other information.. these tables are linked through forein keys... now what i want to do is, i want to select a value from main table suppose, ID 10, and i want to display it in other gridview having the children table values of the ID 10. how can i achieve this scenario? Please let me know if i am not clear with my statements. Thank U-Jigzy-Please remember to click “Mark as Answer” on the post that helps you.This can be beneficial to other members reading the thread. You can have y...

Web resources about - Selecting a gridview row and keeping the last selected row in a gridview highlighted after mouse moves over a new row. -

File:Adams County Iowa Incorporated and Unincorporated areas Carbon Highlighted.svg - Wikipedia, the ...
This map shows the incorporated and unincorporated areas in Adams County , Iowa , highlighting Carbon in red. It was created with a custom script ...

Facebook gauges interest in new way to monetize users: ‘highlighted posts’
... PayPal, a credit card or Facebook Credits they have saved. The promoted post will appear at the top of friends’ News Feeds with the word “highlighted” ...

All sizes - 20110120-NodeXL-Twitter-Quantified Self Graph Highlighted Most Between User with tooltip ...
Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to ...

Environment Agency Abu Dhabi’s achievements highlighted
The Environment Agency Abu Dhabi’s report for last year details an impressive series of achievements in conservation and sustainability.

ACT's mental health system failures highlighted in Peter Zovak inquest findings
Inquest into territory's mental health system hears Canberra man begged for help just days before his brother died by suicide.

State of Origin: The verbal exchange that highlighted the NSW Blues' winning attitude in game 2
... in Origin I A heated exchange between Corey Parker, the oldest member of the Queensland team, and David Klemmer, the youngest NSW player, highlighted ...

State of Origin: The verbal exchange that highlighted the NSW Blues' winning attitude in game 2
... in Origin I A heated exchange between Corey Parker, the oldest member of the Queensland team, and David Klemmer, the youngest NSW player, highlighted ...

Lions among species decline highlighted by IUCN Red List of endangered species
Conservationists' celebrations of species recoveries have been overshadowed by the increase in animal species threatened with extinction.

Refugee crisis highlighted in Africa film festival
Drawing a global audience, Nigerian cinema highlighting issues close to the society's heart.

Facebook cancelled a student's internship after he highlighted a massive privacy issue
Facebook cancelled a Harvard student's internship after he created a Google Chrome plugin that highlighted serious privacy flaws in the social ...

Resources last updated: 1/12/2016 1:32:47 AM