Search data in DataGridView using FilterDataRow VB.Net

Viewed 175
    DV = New DataView(ds.Tables("CustomerList"))
    FlxCustomerList.DataSource = ds.Tables("CustomerList").DefaultView 
    myDataTable = CType(FlxCustomerList.DataSource, DataView).ToTable                 
    drToAdd = myDataTable.NewRow()
    drToAdd("Customer Account") = ""
    drToAdd("Customer Name") = "" 
    drToAdd("Customer Group") = "" 
    drToAdd("City") = ""
    drToAdd("Mobile No") = ""
    drToAdd("Status") = ""
    myDataTable.Rows.InsertAt(drToAdd, 0)
    myDataTable.AcceptChanges()
    FlxCustomerList.DataSource = myDataTable.DefaultView
    For Each dtrow As DataGridViewRow In FlxCustomerList.Rows
        If dtrow.Index = 0 Then
            dtrow.Frozen = True
        Else
            dtrow.ReadOnly = True
        End If
    Next

To achieve the search in Datagridview functionality, I'm getting the first row by this, on search enter, key-down function call this

CustomerAccountFilterStr = CStr(Me.DataGridView1.Rows(0).Cells("CustomerAccount").Value)
sStr = sStr & " [Customer Account] like '%" & CustomerAccountFilterStr & "%'"
ds.Tables("CustAcc").DefaultView.RowFilter = sStr

This is how I binding Data to DataGridView

myDataView.RowFilter = sStr
FlxCustomerList.DataSource = myDataView

And Then The DataGridView which is bound to the DefaultView of DataSet. I froze the first row but now, couldn't understand how to put back filtered values from the second-row onwards to the grid.

enter image description here

The example output should resemble like below.

this

I'm stuck to implement this functionality. please guide How to implement this functionality?

0 Answers
Related