Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, January 2, 2013 7:32 AM
Hi,
I am using **radcombobox **in my project, bind the combo box using page methods see this link.(last method) Working fine to display the items based on loadondemond, but after save the data when i am trying to edit i am assigning to radcombobox based on item value , but it is not working properly, because radcombobox items are not loaded .
my code is
i am trying bellow two ways
- RadComboBox4.SelectedValue = dr["AgentID"].ToString();
2) RadComboBox4.FindItemByValue(dr["AgentID"].ToString()).Selected = true;
the second method showing the error , selecteditem and selectedindex always shows null and -1.
please can any one help me to come out this problem .
Thanks,
hemanth
All replies (6)
Wednesday, January 2, 2013 8:21 AM
What i know findbyvalue/findbytext is case sensitive, so make sure about the case
if (RadComboBox4.FindItemByValue(dr["AgentID"].ToString()) != null)
{
RadComboBox4.FindItemByValue(dr["AgentID"].ToString()).Selected = true;
}
Wednesday, January 2, 2013 8:55 AM
Hi oned , thanks for reply
I checked that code but same problem, i think there is no items in Radcombobox4 assigning time, but code is correct AgentId matching value is there in radcombobox but it always shows null.
Wednesday, January 2, 2013 9:04 AM
make sure you rcb already bound before make selection
if (!ispostback)
{
RadComboBox4.DataBind()
}
//make selection here
Wednesday, January 2, 2013 9:35 AM
there is no binding in radcombobox , my code is
default.aspx.cs page
[WebMethod]
public static RadComboBoxData GetCompanyNames(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]["Name"].ToString();
itemData.Value = data.Rows[i]["ID"].ToString();
result.Add(itemData);
}
comboData.Message = GetStatusMessage(endOffset, data.Rows.Count);
comboData.Items = result.ToArray();
return comboData;
}
default.aspx
<telerik:RadComboBox ID="RadComboBox4" runat="server" Width="250px" Height="150px"
EmptyMessage="Select a Company" EnableLoadOnDemand="true" ShowMoreResultsBox="true"
EnableVirtualScrolling="true" Label="Page Methods:" AutoPostBack="true" OnSelectedIndexChanged="RadComboBox4_SelectedIndexChanged">
<WebServiceSettings Method="GetCompanyNames" Path="ClientInfo.aspx" />
</telerik:RadComboBox>
RadComboBox4_SelectedIndexChanged event
if (RadComboBox4.SelectedValue != "")
{
AgentId = Convert.ToInt32(RadComboBox4.SelectedValue);
hideddlAgent.Text = RadComboBox4.SelectedValue;
}
-->SelectedValue and text only display the data remaining selectedindex and selecteditem all are no values .
Thursday, January 3, 2013 7:02 AM
Hi,
By design when a RadComboBox with enabled Load-On-Demand feature is loaded - it is empty and it has no items. Load-On-Demand fires and populates the control with data if the user types in the input area or clicks on the drop-down toggle image when there are no items in the RadComboBox.
Additionally the RadComboBox items are not accessible on the server-side when loading them on demand and that is why they cannot be accessed using the server-side FindItemByText / Value methods - please take a look at this help article.
Thanks,
Shinu.
Thursday, January 3, 2013 8:15 AM
try set AutoPostBack="false"