Hi all,
According your demo on usibng web services to load data on demand:
http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx
if I remove the 'static' code from the method in the code behind CS page I get the error :
"The server method has failed' as a popup box.
Here is my code behind:
:
According your demo on usibng web services to load data on demand:
http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx
if I remove the 'static' code from the method in the code behind CS page I get the error :
"The server method has failed' as a popup box.
Here is my code behind:
public
const
int
ItemsPerRequest = 10;
[WebMethod]
public
RadComboBoxData GetDealNumbers(RadComboBoxContext context)
{
DataTable data = GetData(context.Text);
RadComboBoxData comboData =
new
RadComboBoxData();
int
itemOffset = context.NumberOfItems;
int
endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);
comboData.EndOfItems = endOffset == data.Rows.Count;
List<RadComboBoxItemData> result =
new
List<RadComboBoxItemData>(endOffset - itemOffset);
for
(
int
i = itemOffset; i < endOffset; i++)
{
RadComboBoxItemData itemData =
new
RadComboBoxItemData();
itemData.Text = data.Rows[i][
"DealNo"
].ToString();
itemData.Value = data.Rows[i][
"DealNo"
].ToString();
result.Add(itemData);
}
comboData.Message = GetStatusMessage(endOffset, data.Rows.Count);
comboData.Items = result.ToArray();
return
comboData;
}
public
DataTable GetData(
string
text)
{
SqlDataAdapter adapter =
new
SqlDataAdapter(
"SELECT new_name as 'DealNo' from new_dealtracking WHERE new_name LIKE @text + '%'"
, Properties.Settings.Default.MSCRMConnectionString);
adapter.SelectCommand.Parameters.AddWithValue(
"@text"
, text);
DataTable data =
new
DataTable();
adapter.Fill(data);
return
data;
}
private
string
GetStatusMessage(
int
offset,
int
total)
{
if
(total <= 0)
return
"No matches"
;
return
String.Format(
"Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>"
, offset, total);
}
My aspx code is:
Why is this the case??
<
telerik:RadComboBox
ID
=
"RadComboBox4"
runat
=
"server"
Width
=
"157px"
Height
=
"150px"
EmptyMessage
=
"Select a Deal"
EnableLoadOnDemand
=
"true"
ShowMoreResultsBox
=
"true"
EnableVirtualScrolling
=
"true"
>
<
WebServiceSettings
Method
=
"GetDealNumbers"
Path
=
"Custom_DealUI.aspx"
/>
</
telerik:RadComboBox
>
Why is this the case??