Solved

Filter Datatable

Posted on 2013-06-07
8
286 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 25

Accepted Solution

by:
Shaun Kline earned 500 total points
Comment Utility
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
Comment Utility
Just need to filter the row which is having the pk value which am passing
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
as started by shaun:

Dim dv as DataView = _title.DefaultView
dv.RowFilter =  "TitleID= '" + titleid.ToString() + "'"
0
 

Author Comment

by:GRChandrashekar
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 69

Expert Comment

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

Author Comment

by:GRChandrashekar
Comment Utility
Didnt understand
0
 
LVL 25

Expert Comment

by:Shaun Kline
Comment Utility
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 69

Expert Comment

by:Éric Moreau
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now