Gridview search using DataTable Datasource

I have a gridview that gets its data from webservice.

This is included in the application in the data set.

   Me.GvStreets.DataSource = TheWebServiceSearch.AddressDataTable
   Me.GvStreets.DataBind()

Once in grid mode, how do I search the contents of this dataset.

Should I add it to some kind of data source control, like an XML data source?

thanks

What I finished was ...

  Dim StreetDataTable As DataTable = Session("StreetData")
   Dim Name As String = StreetDataTable.Columns(0).ColumnName

   Dim FilteredResults As New DataTable
   FilteredResults = StreetDataTable.Clone()

   Dim DataRows() As DataRow
   DataRows = StreetDataTable.Select("street LIKE '%" & Me.txtStreet.Text & _


                         "%'", "Street ASC")
    Dim i As Integer

    For i = 0 To DataRows.GetUpperBound(0)

        FilteredResults.ImportRow(DataRows(i))

    Next i

    Me.GvStreets.DataSource = FilteredResults
    Me.GvStreets.DataBind()

I needed to get the results and clone the data table to get the schema. Then I made a choice from the original datatable. I went through the results and added them to the cloned data table.

+3
source share
1 answer

, , TheWebServiceSearch.AddressDataTable DataTable, :

DataTable data = TheWebServiceSearch.AddressDataTable;
DataRow[] foundRows = data.Select("city = 'NY'", "zip ASC");

DataTable.Select


, , . , - . DataView ( ). :

Dim StreetDataTable As DataTable = Session("StreetData")
Dim Name As String = StreetDataTable.Columns(0).ColumnName
StreetDataTable.DefaultView.RowFilter = "street LIKE '%" & Me.txtStreet.Text & "%'"
StreetDataTable.DefaultView.Sort = "Street ASC"

Me.GvStreets.DataSource = StreetDataTable.DefaultView
Me.GvStreets.DataBind()

DataView.

+5

Source: https://habr.com/ru/post/1709204/


All Articles