Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Filter Datatable

Posted on 2013-06-07
8
Medium Priority
?
296 Views
Last Modified: 2013-06-07
Hi,

I am trying to filter data table _title on its PK by passing titleid through a function. But it does not work.

Private Sub Fetchrecord(titleid As String)
       
            '_title.Select("TitleID = " + titleid)
            _title.DefaultView.RowFilter = "TitleID= '" + titleid.ToString() + "'"
                 
    End Sub
I tried both the above lines Still no luck

PS: I have tried all links available on google but no luck
0
Comment
Question by:GRChandrashekar
[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
  • 3
  • 3
  • 2
8 Comments
 
LVL 27

Accepted Solution

by:
Shaun Kline earned 2000 total points
ID: 39228842
What is your goal for filtering the datatable? Do you need to bind the result to control(s)? Do you need to find values in that same row?

The commented out line will return an array of datarows.
The second modifies the defaultview of the table, but not the table itself.

Try:
Dim dv as DataView = _title.DefaultView
dv.RowFilter = "<filter>"

Then use dv.
0
 

Author Comment

by:GRChandrashekar
ID: 39228861
Just need to filter the row which is having the pk value which am passing
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 39228885
as started by shaun:

Dim dv as DataView = _title.DefaultView
dv.RowFilter =  "TitleID= '" + titleid.ToString() + "'"
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:GRChandrashekar
ID: 39228886
Dim dv as DataView = _title.DefaultView
dv.RowFilter = "<filter>"

This filters the grid itself which has binding ! I just need to find row without affecting my databinding
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 39228913
just bind your grid to the dataview instead of the datable!
0
 

Author Comment

by:GRChandrashekar
ID: 39228918
Didnt understand
0
 
LVL 27

Expert Comment

by:Shaun Kline
ID: 39228922
Going back to my original question, once you have the row with that PK, what are you going to do with it?

There are a number of ways to get that row in various object types. Understanding what you wish to do with the datarow will help us find an answer for you that works.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 39228925
your grid is currently bound to _title? make the dataview a member with a scope of the form and bind your grid to this new dataview variable
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

604 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