Solved

Filter Datatable

Posted on 2013-06-07
8
290 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
  • 3
  • 3
  • 2
8 Comments
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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 26

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Generate Numbers in JQuery file 11 66
Very Large data in MYSQL 7 73
ASP.NET (VB) return a record 2 35
Get month and date in a format 4 31
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

808 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