0

以下のコードを使用してテキストボックスにオートコンプリートを入力しています。選択すると、rowid ではなく、選択したテキストだけが表示されます。alert(eventArgs.get_value()) が SQL の行の実際の ID を返さない理由は何ですか?

<script language="javascript" type="text/javascript">
    function getSelected(source, eventArgs) {
        alert(eventArgs.get_value())

    }
</script>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    AutoCompleteExtender.OnClientItemSelected = "getSelected"

End Sub

Public Function GetCompletionList(prefixText As String, count As Integer, ByVal contextKey As String) As String()
    Try
        Dim Con As SqlConnection
        Dim cmd As SqlCommand
        Con = New SqlConnection
        Dim test As String
        test = contextKey
        Con.ConnectionString = ""
        Con.Open()

        cmd = New SqlCommand
        cmd.Connection = Con
        'cmd.CommandText = "SELECT NPI, [Entity Type Code], [Provider Last Name (Legal Name)], [Provider First Name], [Provider Business Mailing Address City Name] FROM NPIData WHERE [Provider Last Name (Legal Name)] LIKE @Provider + '%' AND [Provider Business Mailing Address City Name] = @State"
        cmd.CommandText = "SELECT NPI, [Entity Type Code], [Provider Last Name (Legal Name)], [Provider First Name], [Provider Business Mailing Address City Name], [Provider Business Mailing Address State Name], [Provider Business Mailing Address Postal Code] FROM NPIData WHERE     ([Provider Business Mailing Address State Name] = @State) AND ([Provider Last Name (Legal Name)] LIKE N'%' + @Provider + N'%') ORDER BY [Provider First Name]"
        cmd.Parameters.AddWithValue("@Provider", prefixText)
        cmd.Parameters.AddWithValue("@State", contextKey)
        Dim customers As List(Of String) = New List(Of String)
        Dim reader As SqlDataReader = cmd.ExecuteReader()


        While reader.Read
            customers.Add(reader("Provider Last Name (Legal Name)").ToString + ", " + reader("Provider First Name").ToString + "          " + reader("Provider Business Mailing Address City Name").ToString + ", " + reader("Provider Business Mailing Address State Name").ToString + "  " + reader("Provider Business Mailing Address Postal Code").ToString)

        End While


        Con.Close()

        Return customers.ToArray
    Catch ex As Exception

    End Try
4

1 に答える 1

0

AutoExtender にデータを入力していないため、行 ID が返されません。基になる値ではなく、テキスト値のみを指定しました。顧客は次のように入力する必要があります (NPI が行 ID であると仮定しますか?)

customers.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(
reader("NPI").ToString,
reader("Provider Last Name (Legal Name)").ToString + ", "
 + reader("Provider First Name").ToString + "          " + reader("Provider Business Mailing Address City Name").ToString + ", " 
+ reader("Provider Business Mailing Address State Name").ToString + "  " + reader("Provider Business Mailing Address Postal Code").ToString))
于 2014-01-16T15:11:34.353 に答える