Hello,
I have a problem in displaying the returned value from Database in the radcombobox. In other words if I put the following code in the RadGrid EditForm then I can't submit the changes (If I click update I recieve an error):
and
Please, can you explain to me what is the problem and how can I fix it.
It is appreciated to send me the modified code.
Regards,
Bader
I have a problem in displaying the returned value from Database in the radcombobox. In other words if I put the following code in the RadGrid EditForm then I can't submit the changes (If I click update I recieve an error):
<telerik:RadComboBox ID="CstmrIDRadComboBox" OffsetX="-20" Skin="Vista" runat="server" Width="250px" Height="150px" AutoPostBack="false" EnableLoadOnDemand="true" ShowMoreResultsBox="true" DataValueField="CstmrID" DataTextField="CstmrName" EnableVirtualScrolling="true" SelectedValue='<%# DataBinder.Eval( Container, "DataItem.CstmrID" ) %>' > <WebServiceSettings Method="GetCstmrsNames" Path="AddBsns.aspx" />and
private const int ItemsPerRequest = 10; [WebMethod] public static RadComboBoxData GetCstmrsNames(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]["CstmrName"].ToString(); itemData.Value = data.Rows[i]["CstmrID"].ToString(); result.Add(itemData); } comboData.Message = GetStatusMessage(endOffset, data.Rows.Count); comboData.Items = result.ToArray(); return comboData; } private static DataTable GetData(string text) { SqlDataAdapter adapter = new SqlDataAdapter("SELECT * from Customers WHERE CstmrName LIKE @text + '%'", ConfigurationManager.ConnectionStrings["MapConnectionString"].ConnectionString); adapter.SelectCommand.Parameters.AddWithValue("@text", text); DataTable data = new DataTable(); adapter.Fill(data); return data; } private static string GetStatusMessage(int offset, int total) { if (total <= 0) return "No matches"; return String.Format("{0} <b>1</b>-<b>{1}</b> {2} <b>{3}</b>", "Customers", offset, "Of", total); }Please, can you explain to me what is the problem and how can I fix it.
It is appreciated to send me the modified code.
Regards,
Bader