Aspx page(Test.aspx)
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="true">
</telerik:RadScriptManager>
<telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" Width="250" DropDownHeight="150"
DropDownWidth="250">
<WebServiceSettings Method="GetCompanyNames" Path="Test.aspx" />
</telerik:RadAutoCompleteBox>
Test.cs
[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
public static AutoCompleteBoxData GetCompanyNames(object context)
{
string searchString = ((Dictionary<string, object>)context)["Text"].ToString();
//DataTable data = GetChildNodes(searchString);
DataTable data = new DataTable();
SqlConnection conn = new SqlConnection(connectionstring);
string sql = "SELECT ID,NAME FROM T_Patient WHERE NAME LIKE '" + searchString + "%'";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
da.Fill(data);
List<AutoCompleteBoxItemData> result = new List<AutoCompleteBoxItemData>();
foreach (DataRow row in data.Rows)
{
AutoCompleteBoxItemData childNode = new AutoCompleteBoxItemData();
childNode.Text = row["NAME"].ToString();
childNode.Value = row["ID"].ToString();
result.Add(childNode);
}
AutoCompleteBoxData res = new AutoCompleteBoxData();
res.Items = result.ToArray();
return res;
}
Some Error is occured when public static AutoCompleteBoxData GetCompanyNames(object context) replace to public AutoCompleteBoxData GetCompanyNames(object context) [remove static keywords]
i am not use public web method or any other idea use only public method /public static method.
THE SERVER METHOD 'GetCompanyNames
' FAILED.
please give me solution.
thank you.
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="true">
</telerik:RadScriptManager>
<telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" runat="server" Width="250" DropDownHeight="150"
DropDownWidth="250">
<WebServiceSettings Method="GetCompanyNames" Path="Test.aspx" />
</telerik:RadAutoCompleteBox>
Test.cs
[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
public static AutoCompleteBoxData GetCompanyNames(object context)
{
string searchString = ((Dictionary<string, object>)context)["Text"].ToString();
//DataTable data = GetChildNodes(searchString);
DataTable data = new DataTable();
SqlConnection conn = new SqlConnection(connectionstring);
string sql = "SELECT ID,NAME FROM T_Patient WHERE NAME LIKE '" + searchString + "%'";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
da.Fill(data);
List<AutoCompleteBoxItemData> result = new List<AutoCompleteBoxItemData>();
foreach (DataRow row in data.Rows)
{
AutoCompleteBoxItemData childNode = new AutoCompleteBoxItemData();
childNode.Text = row["NAME"].ToString();
childNode.Value = row["ID"].ToString();
result.Add(childNode);
}
AutoCompleteBoxData res = new AutoCompleteBoxData();
res.Items = result.ToArray();
return res;
}
Some Error is occured when public static AutoCompleteBoxData GetCompanyNames(object context) replace to public AutoCompleteBoxData GetCompanyNames(object context) [remove static keywords]
i am not use public web method or any other idea use only public method /public static method.
THE SERVER METHOD 'GetCompanyNames
' FAILED.
please give me solution.
thank you.