Hi all,
I need to do the autocomplete textbox in asp.net website, for that i am using ajax post to get the the datatable
Here is my client side code :
------------------------------------------------------------------------------
$(function () {
debugger;
var availableTags = getbroker()
});
function getbroker() {
var RejectedCount;
$.ajax({
type: 'POST',
url: 'common.aspx/get_broker',
contentType: 'application/json; charset=utf-8',
data: '{"amc":"' + strcorp + '","schema":"' + ucode + '"}',
dataType: 'json',
async: false,
success: function (r) {
alert("sucess");
RejectedCount = r.d;
get_new(RejectedCount)
}, error: function (x, e) {
alert("error");
}
});
}
function get_new(RejectedCount) {
$("#txt_broker").autocomplete({
source: RejectedCount
});
}
Server side(first way)
-------------------------------------------------------------------------
<webmethod()>
Public Shared Function get_broker(ByVal amc As String, ByVal schema As String) As string
Dim dt As DataTable
Dim output As New StringBuilder
Try
dt= here i am get the datatable using stored procedure
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
output.Append("(")
For i As Integer = 0 To dt.Rows.Count - 1
output.Append("" & dt.Rows(i)("brok_dlr_code").ToString() & "")
If i <> dt.Rows.Count - 1 Then
output.Append(",")
End If
Next
output.Append(")")
Return output.ToString()
End If
Catch ex As Exception
End Try
End Function
Second way
-------------------------------------------------------------------------------
<WebMethod()>
Public Shared Function get_broker(ByVal amc As String, ByVal schema As String) As DataTable
Dim dt As DataTable
Try
dt= here i am get the datatable using stored procedure
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
Return dt
End If
Catch ex As Exception
End Try
End Function
I have tried with first way and second way... both are getting error alert msg
so please any one help me
my requirements
---------------
i have to get the string values from the datatable . while i m typing the related values should be come under the textbox
i m strugling with 2 days...
thanks in advansce
Velsamy