Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with selecting rows in Grid based on string value

Posted on 2013-01-03
8
Medium Priority
?
354 Views
Last Modified: 2013-01-04
Hi,
 I tried the code below to select rows 2 and 3 (utubeC = "1,2") but getting error message: Not supported when the Grid is bound
on line:
If utubeC.Split(",").Contains(C1SDeactivation.Rows(i).ToString) Then
 
utubeC = "1,2"
C1SDeactivation.ClearFields()
For i As Integer = 0 To C1SDeactivation.RowCount - 1
If utubeC.Split(",").Contains(C1SDeactivation.Rows(i).ToString) Then
C1SDeactivation.SelectedRows.Add(i)
End If
Next
 
How do I fix this error?
 
I am using a TrueDBGrid from componentOne, but hoping solution for GridView will also solve this issue.

Victor
0
Comment
Question by:vcharles
  • 4
  • 4
8 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38742085
>If utubeC.Split(",").Contains(C1SDeactivation.Rows(i).ToString) Then

Should that not be

If utubeC.Split(",").Contains(C1SDeactivation.Rows(i).Cells(CellIndex).Value.ToString) Then
0
 

Author Comment

by:vcharles
ID: 38742175
Hi,

Thanks for the code, when I tried it, I received error messsage: "CellIndex is not declared it may be inaccessible due toi its protection level.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38742234
When I use undeclared variables in my code examples, I expect you to replace those appropriately. What CellIndex meant is... index of the column that you are trying to check (such as ID) just like you are using i as rowindex.
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Author Comment

by:vcharles
ID: 38742274
I am checking the string variable against the first column in the Grid.

 SDeactivation_ID  SDeactivation
0                             ItemA
1                             ItemB
2                             ItemC
3                             ItemD

Tried the following code:

 If utubeC.Split(",").Contains(C1SDeactivation.Rows(i).Cells(SDeactivation_ID).Value.ToString) Then

But it still does not work. Error SDeactivation is not declared,it may be inaceesible to to its protection level.

Also tried:

 If utubeC.Split(",").Contains(C1SDeactivation.Rows(i).Cells("SDeactivation_ID").Value.ToString) Then
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 38742349
Also try

If utubeC.Split(",").Contains(C1SDeactivation.Rows(i).Cells(0).Value.ToString) Then

Note that .Cells is a GridView way of doing this. Your control may have some other name to correspond to this or may not have this at all.
0
 

Author Comment

by:vcharles
ID: 38742502
That also did not work, waiting to hear back from componentOne.

Thanks,

Victor
0
 

Author Comment

by:vcharles
ID: 38742561
I'm not getting an error with code below but i  is stuck in 0, any ideas why?
I tried i = i + 1 within the loop but msgbox value only shows 0, which i assume is the value for the first row.

 For i As Integer = 0 To C1SDeactivation.RowCount - 1
            MsgBox(C1SDeactivation.Columns(0).Value.ToString)
                    If utubeC.Split(",").Contains(C1SDeactivation.Columns(0).Value.ToString)
Then
 C1SDeactivation.SelectedRows.Add(i)
            End If
        Next
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38743320
You are only using .Columns collection without any reference to a row hence same value all the time.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

916 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