this is the code i used to search a datagrid
Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
Dim strFilter As String = ""
For Each col As DataColumn In Me._main.Columns
If Me.grdTask.Columns(col.ColumnName).Visible = True Or Not String.IsNullOrEmpty(col.Expression) Then
Dim strClause As String = "CONVERT(" & col.ColumnName & ",'System.String') LIKE '*" & Me.txtSearch.Text & "*'"
If strFilter = "" Then
strFilter &= strClause
Else
strFilter &= " OR " & strClause
End If
End If
Next
Me.bndTask.Filter = strFilter
End Sub
but i need this part of the code as well to get the search working correctly
Me._datset.Relations.Add(TableName & "_" & Me._main.TableName, _
tbl.Columns(IDColumn), Me._main.Columns(IDColumn))
Dim datCol As New DataColumn(DisplayColumn)
datCol.DataType = tbl.Columns(DisplayColumn).DataType
datCol.Expression = "Parent(" & TableName & "_" & Me._main.TableName & ")." & DisplayColumn
Me._main.Columns.Add(datCol)
Me.grdMain.Columns(DisplayColumn).Visible = False
any one have anyidea what the best way to do this is
Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
Dim strFilter As String = ""
For Each col As DataColumn In Me._main.Columns
If Me.grdTask.Columns(col.ColumnName).Visible = True Or Not String.IsNullOrEmpty(col.Expression) Then
Dim strClause As String = "CONVERT(" & col.ColumnName & ",'System.String') LIKE '*" & Me.txtSearch.Text & "*'"
If strFilter = "" Then
strFilter &= strClause
Else
strFilter &= " OR " & strClause
End If
End If
Next
Me.bndTask.Filter = strFilter
End Sub
but i need this part of the code as well to get the search working correctly
Me._datset.Relations.Add(TableName & "_" & Me._main.TableName, _
tbl.Columns(IDColumn), Me._main.Columns(IDColumn))
Dim datCol As New DataColumn(DisplayColumn)
datCol.DataType = tbl.Columns(DisplayColumn).DataType
datCol.Expression = "Parent(" & TableName & "_" & Me._main.TableName & ")." & DisplayColumn
Me._main.Columns.Add(datCol)
Me.grdMain.Columns(DisplayColumn).Visible = False
any one have anyidea what the best way to do this is