How and where can you check a RadComboBox for a value? I am getting an error because I am trying to set the selected value of my RCB to a value in my grid that I use databinder to get at. If the value is not in the original dataset I bound to my RCB it errors out. What I want to do is when I open my custom edit form that has this RCB in it, check to see if the value from the grid exists in the available items of the RCB. I cannot add it as it is no longer a valid option but my client keeps it for historical records. I am calling the following code in the pageLoad method but it is not working as it seems as if the RCB data items are not available here.
myDDL.DataTextField = ds.Tables[0].Columns["DATA"].ToString();
myDDL.DataValueField = ds.Tables[0].Columns[0].ToString();
myDDL.DataSource = ds.Tables[0];
var myValue = String.Empty;
var ddlValue = DataBinder.Eval(DataItem, "DATA");
Session["ddlValue"] = ddlValue;
myValue = Session["ddlValue"].ToString();
if (DataItem != null)
{
if (myDDL.FindItemByValue(ddlValue.ToString()) == null)
{
myDDL.SelectedIndex = -1;
}
else
{
myDDL.SelectedValue = ddlValue.ToString();
}
}
else
{
myDDL.SelectedValue = myValue;
}
}