?
Solved

VB 2008  - Attempting to select all DataGridView rows

Posted on 2009-07-09
5
Medium Priority
?
453 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

762 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