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 way to do it?  Anyone here has done this before can guide me through this?  Thank you so much.

3/19/2009 6:38:49 PM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 7

The SelectedRowIndex of a GridView is an integer, not an array.  I don't know what sort of functionality you'd expect to get.  You could add a checkbox control column to the row template and let people select multiple rows that way, although you wouldn't actually be "selecting" the rows in any way that would be accessible through the built-in methods of the GridView.

If you are feeling ambitious, write your own control with a SelectedRowsIndex as an integer array.

I love to display the non-secure items...
Charlie Asbornsen
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
3/19/2009 7:46:20 PM

I'm trying to avoid the checkbox control or select command control in the gridview. Basically, I want to have the functionality to select multiple rows showing in the gridview.  I'm wondering if there is an alternate way to do it without adding a checkbox control  in the row?

 The problem I'm having right now is that I can't keep the previous row selected when I select another row. It deselect the previous one.  I'm trying to achieve this task as the sample below:

For example, if I select row 2 and row 5, these 2 rows will be highilighted and the count for row selected is 2


3/19/2009 8:49:19 PM

You could look at some third party tools:

I love to display the non-secure items...
Charlie Asbornsen
Dont forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
3/19/2009 8:54:02 PM

Hi boston_ma,

Here is an article about how to implement multiple rows selection in GridView. It stores the primary key of each selected rows into Session, and change the color of selected rows.


Qin Dian Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
3/24/2009 6:21:54 AM

Similar Artilces:

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? Thanks, Steve hi,you can use <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="#FFFFFF" /> plz let me know if i misunderstood you 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? Thanks, Steve hi, sorry i din...

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...

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 ...

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...

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...

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...

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.    ...

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...

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...

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 ...

Data Controls insert rows into gridview then insert rows from gridview into SQL Table
Hello there, I'm still new at performing miracles with code . Currently I am having trouble with my latest coding adventure I have a web application which records jobs and labour assigned to jobs. The issue in particular I'm having is the way in which labour is to be assigned. I want to use standard controls (Textbox, Dropdownlist) to record the values into a gridview (ie,put multiple rows into the gridview using the controls). Then, when all the inserting is complete, the user clicks a submit button to insert all the rows from the gridview into a database table. The reason for...

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$" &...

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...

Select multiple rows in GridView without using a Select Command ?
Hello, Does anyone knows a way to select multiple rows in GridView without using a Select command, control button or a checkbox control? Thank you very much. olaamigos:Does anyone knows a way to select multiple rows in GridView without using a Select command, control button or a checkbox control?  I believe that this is what you are looking for:GridView Clickable Rows Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET Thanks Vinz for replying, The  sample in the "GridView Cl...