guys, i have this function:

Public Function GetDataSource(ByVal dataItem As Object) As DataTable
        Dim intNo As String = DataBinder.Eval(dataItem, "Item_No")
        Dim blahdt As DataTable = tempdt
        'blahdt.DefaultView.RowFilter = "Item_No='" & intNo & "'"        
'blahdt.Select("Item_No='" & intNo & "'")
Return blahdt
    End Function

i want to filter my datatable, i tried both the colored lines...the second one did not work...the first one worked but it did not retain the changes i made to my datatable...it gave the default view of the datatable...

any suggestions...

thanks

Recommended Answers

All 4 Replies

please ignore this post...i got it solved...

please ignore this post...i got it solved...

Hello,
I am having the same problem. I am trying to use the DataTable object and an array of DtaaRows from the Select method on the Table. I keep getting exceptions that the column does not exist when it does. I have created a DataGridView to display for debugging purposes and it has the DataSet from my initial select populated but when I try to filter it in memory it won't.

I don't want to have to continually goto the database for the data that I have in this dataset. I have the data so I would like to be able to filter it depending on what I have in another control.

Anyone who has the answer to this would be appreciated.

Thanks,
Catrece

TRY WITH MY BELOW EXAMPLE. HOPE IT WILL HELP YOU.
VB.NET:

Dim sClause as String  
Dim drItems() as DataRow  
sClause = "Price > 50"  
drItems = dsPrepopulatedDBData.Tables(0).Select(sClause)

C#.NET

DataRow[] drItems = dtPrepopulatedDBData.Select( "Price > 50", "" );

Hello Everyone,

Although DefaultView provides limited ways to filter out the row set of a datatable. However you people should use the power of LINQ to query from record set of a in memory datatable. below is the code:

IEnumerable<DataRow> rowSet = from employee in dt.AsEnumerable()
               where employee.Field<string>("Name").StartsWith("N")
               select employee;

Further, to get the complete insight of LINQ on DataTables visit

Best Rgds

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.