公共共享CreateAutoCompleteItem的参数太多

时间:2012-03-01 16:58:23

标签: vb.net webmethod autocompleteextender

我没有为AutoCompleteExtender编写函数,所以我不太确定如何更改它而不搞砸它,所以我想我会问这里。最近,要求AutoComplete显示产品名称&该特定产品的发布日期。我不知道如何将日期添加到AutoComplete。

需要这样做的原因是因为我们提供的网络研讨会将来会再次显示,因此在数据库中有多个具有相同名称的网络研讨会。在搜索时,如果有3个名称完全相同,选择一个网络研讨会有点困难,所以如果它显示名称和日期,我会想象选择合适的名称会更容易!

现在写这个的方式不正确。我在launchdate行中的Dim item As String = AjaxControlToolkit......字词下方得到了一条曲线,错误是:Too many arguments to 'Public Shared Function CreateAutoCompleteItem(text As String, value As String) As String'

非常感谢任何帮助!就像我说的那样,我没有写这个,所以我甚至都不知道这是不是最好的做法。我理解你是否要批评代码,如果需要它我会改变它,但我真的想知道如何添加额外的字段。谢谢!

Public Function GetProducts(ByVal prefixText As String, ByVal count As Integer) As String()
    Dim ProductSql As String = "Select DISTINCT ProductID, ProductName, LaunchDate 
                                FROM Product 
                                WHERE ProductName LIKE '%' + @prefixText + '%' 
                                AND LaunchDate IS NOT NULL 
                                ORDER BY ProductName ASC"
    Using sqlConn As New SqlConnection
(System.Configuration.ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString)
        sqlConn.Open()
        Dim myCommand As New SqlCommand(ProductSql, sqlConn)
        myCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = prefixText
        Dim myReader As SqlDataReader = myCommand.ExecuteReader()
        Dim myTable As New DataTable
        myTable.TableName = "ProductSearch"
        myTable.Load(myReader)
        sqlConn.Close()
        Dim items As String() = New String(myTable.Rows.Count - 1) {}
        Dim i As Integer = 0
        For Each dr As DataRow In myTable.Rows
            Dim id As String = dr("ProductID").ToString()
            Dim name As String = dr("ProductName").ToString()
            Dim launchdate As String = dr("LaunchDate").ToString()
            Dim item As String = 
            AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(name, id, launchdate)
            items.SetValue(item, i)
            i += 1
        Next
        Return items
    End Using
End Function

1 个答案:

答案 0 :(得分:0)

试试这个..

AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(name & " " & launchdate, id)