Solved

VB 2008  - Attempting to select all DataGridView rows

Posted on 2009-07-09
5
439 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 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