Solved

VB 2008  - Attempting to select all DataGridView rows

Posted on 2009-07-09
5
438 Views
Last Modified: 2012-05-07
I am attempting to select all the grid's rows but failing.  I just don't know how to write this code.

Although the grid is named  EvalItemsDataGridView the design-time compiler says it "is not a collection type".

        For Each row As DataGridViewRow In EvalItemsDataGridView
            DataGridViewRow.CurrentRow.Selected = True
        Next
0
Comment
Question by:ljcor
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:divyeshhdoshi
ID: 24812261
Hi,


In asp.net gridview you can not select multiple rows at a time. If you try to do  so
using
        For Each row As DataGridViewRow In EvalItemsDataGridView
            DataGridViewRow.CurrentRow.Selected = True
        Next


then it will select last selected row.

To select multiple rows you need to extend functionality of gridview.
http://www.codeproject.com/KB/aspnet/Extend_GridView.aspx
http://www.aspnetworld.com/articles/2007041601.aspx
0
 

Author Comment

by:ljcor
ID: 24812298
OK, but let's start with the VB problem I mention in the initial question:  what is wrong with the portion of the statement: EvalItemsDataGridView - when that is the name of the grid?
0
 
LVL 6

Accepted Solution

by:
divyeshhdoshi earned 250 total points
ID: 24812338
Datagrid is not a collection

for that you need to specify

        For Each row As DataGridViewRow In EvalItemsDataGridView.Rows
            DataGridViewRow.CurrentRow.Selected = True
        Next
0
 
LVL 47

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 250 total points
ID: 24812410
To select all rows, simply use this....

    DataGridView1.SelectAll()

Wayne
0
 

Author Closing Comment

by:ljcor
ID: 31601511
Both responses are very helpful to me for other work.  Thanks to each of you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 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

20 Experts available now in Live!

Get 1:1 Help Now