Dim ThisDataTable As New Data.DataTable
ThisDataTable.ReadXml("C:\TableData.xml")
'This code requires a DropDownList called ColumnsDropDownList
If ColumnsDropDownList.Items.Count < 1 Then
For Each ThisColumn As Data.DataColumn In ThisDataTable.Columns
ColumnsDropDownList.Items.Add(ThisColumn.ColumnName)
Next ThisColumn
End If
Dim FilteredDataView As Data.DataView = ThisDataTable.DefaultView
'This code requires a TextBox called SearchTextBox
If SearchTextBox.Text <> "" Then
Dim FilterText As String = String.Format("convert([{0}],'System.String') like '%{1}%'", ColumnsDropDownList.SelectedValue, SearchTextBox.Text)
FilteredDataView = New Data.DataView(ThisDataTable, FilterText, Nothing, Data.DataViewRowState.CurrentRows)
End If
GridView1.DataSource = FilteredDataView
GridView1.DataBind()
Tips and tricks for .NET using ASP and VB code.
Generic data viewer with filter
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment