本文介绍了'DataBind'不是'System.Windows.Controls.DataGrid'的成员。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我尝试使用lucene.net在wpf应用程序中索引搜索器,但是在数据绑定中,数据没有出现在数据网格中并导致错误。

 私有  Sub  Btn_Show_Click(发件人 As   Object ,e  As  RoutedEventArgs)
' 尝试
' 结果收集为列表
Dim 搜索结果作为 新列表( SearchResults)()
Dim dt_Result 作为 新 DataTable
Dim searchString 作为 字符串 = txtSearch.Text
Dim query1 作为 字符串 = SELECT RecID,Tag,SbFldSrNo,SbFld,FValue,FValue_TBIL FROM biblidetails
conn.Open()
adap.SelectCommand = 新 SqlCommand(query1,conn)
adap.Fill(dt_Result)
' End If
Dim Field0,Field1,Field2,Field3,Field4,Field5 作为 字符串

Field0 = dt_Result.Columns( 0 )。标题
Field1 = dt_Result.Columns( 1 )。标题
Field2 = dt_Result.Columns( 2 ).Caption
Field3 = dt_Result.Columns( 3 )。标题
Field4 = dt_Result.Columns( 4 )。标题
Field5 = dt_Result.Columns( 5 )。标题

conn。关闭()

' 指定索引文件的存储位置
Dim indexFileLocation 作为 字符串 = C:\ Users \Shahrukh \ Files \ Visual Studio 2012 \Projects \Simple search1 \简单搜索1 \新文件夹
Dim dir 作为 Lucene.Net。 Store.Directory = Lucene.Net.Store.FSDirectory.GetDirectory(indexFileLocation)

' 指定搜索字段,在多个字段中进行lucene搜索
Dim searchfields 作为 字符串()= 新 字符串(){Field0,Field1,Field2,Field3,Field4,Field5}
Dim indexSearcher 正如 新 IndexSearcher(dir)

' 进行搜索的布尔查询并获取搜索到的点击数
Dim hits = indexSearcher.Search(QueryMaker( searchString,searchfields))

对于 i As 整数 = 0 hits.Lengt h() - 1

Dim 结果作为 新 SearchResults()

result.RecID = hits.Doc(i).GetField(Field0)。 StringValue()
result.Tag = hits.Doc(i).GetField(Field1).StringValue()
result.SbFldSrNo = hits.Doc(i).GetField(Field2).StringValue()
result.SbFld = hits.Doc(i).GetField(Field3).StringValue()
result.FValue = hits.Doc(i).GetField(Field4).StringValue()
结果.FValue_TBIL = hits.Doc(i).GetField(Field5).StringValue()

SearchResults.Add(result)

下一步

indexSearcher.Close()

dGridResults.ItemsSource = Searchresults
dGridResults.DataBind()这里有一个错误
' Catch ex As Exception
' MsgBox(ex.Message)
' 结束尝试
结束 Sub
解决方案

hi i am try to index searcher in wpf application using lucene.net but into data bind the data did not comes in data grid and cuases an error .

Private Sub Btn_Show_Click(sender As Object, e As RoutedEventArgs)
    'Try
    ' Results are collected as a List
    Dim Searchresults As New List(Of SearchResults)()
    Dim dt_Result As New DataTable
    Dim searchString As String = txtSearch.Text
    Dim query1 As String = "SELECT RecID, Tag, SbFldSrNo, SbFld, FValue, FValue_TBIL FROM biblidetails"
    conn.Open()
    adap.SelectCommand = New SqlCommand(query1, conn)
    adap.Fill(dt_Result)
    'End If
    Dim Field0, Field1, Field2, Field3, Field4, Field5 As String

    Field0 = dt_Result.Columns(0).Caption
    Field1 = dt_Result.Columns(1).Caption
    Field2 = dt_Result.Columns(2).Caption
    Field3 = dt_Result.Columns(3).Caption
    Field4 = dt_Result.Columns(4).Caption
    Field5 = dt_Result.Columns(5).Caption

    conn.Close()

    ' Specify the location where the index files are stored
    Dim indexFileLocation As String = "C:\Users\Shahrukh\Documents\Visual Studio 2012\Projects\Simple search1\Simple search1\New folder"
    Dim dir As Lucene.Net.Store.Directory = Lucene.Net.Store.FSDirectory.GetDirectory(indexFileLocation)

    ' specify the search fields, lucene search in multiple fields
    Dim searchfields As String() = New String() {Field0, Field1, Field2, Field3, Field4, Field5}
    Dim indexSearcher As New IndexSearcher(dir)

    ' Making a boolean query for searching and get the searched hits
    Dim hits = indexSearcher.Search(QueryMaker(searchString, searchfields))

    For i As Integer = 0 To hits.Length() - 1

        Dim result As New SearchResults()

        result.RecID = hits.Doc(i).GetField(Field0).StringValue()
        result.Tag = hits.Doc(i).GetField(Field1).StringValue()
        result.SbFldSrNo = hits.Doc(i).GetField(Field2).StringValue()
        result.SbFld = hits.Doc(i).GetField(Field3).StringValue()
        result.FValue = hits.Doc(i).GetField(Field4).StringValue()
        result.FValue_TBIL = hits.Doc(i).GetField(Field5).StringValue()

        SearchResults.Add(result)

    Next

    indexSearcher.Close()

    dGridResults.ItemsSource = Searchresults
    dGridResults.DataBind() here comes an error
    'Catch ex As Exception
    'MsgBox(ex.Message)
    'End Try
End Sub
解决方案


这篇关于'DataBind'不是'System.Windows.Controls.DataGrid'的成员。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 15:42