Link to home
Start Free TrialLog in
Avatar of GRChandrashekar
GRChandrashekarFlag for India

asked on

Filter Datatable

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
ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GRChandrashekar

ASKER

Just need to filter the row which is having the pk value which am passing
as started by shaun:

Dim dv as DataView = _title.DefaultView
dv.RowFilter =  "TitleID= '" + titleid.ToString() + "'"
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
just bind your grid to the dataview instead of the datable!
Didnt understand
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.
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