I know this is duplicate question. I have try finding the solution in duplicate question but I failed.
The situation is I have 2 combo box (Telerik Winforms) called ComboBranch and ComboPanel. ComboPanel will show different value when user select the some value in ComboBranch.
So this is the code
private void tbDropBranch_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
dataPanel();
}
void dataPanel()
{
DataTable dtPanel = dataBinding._valuePanel(Convert.ToInt32(tbDropBranch.SelectedValue.ToString())); // Error in here
tbDropPanel.DataSource = new BindingSource(dtPanel, null);
tbDropPanel.DisplayMember = "panelName";
tbDropPanel.ValueMember = "panelID";
}
UPDATE
If I do Event tbDropBranch_Leave it`s work. But why I got error when I use tbDropBranch_SelectedIndexChanged ?
private void tbDropBranch_Leave(object sender, EventArgs e)
{
dataPanel();
}
SOLUTION
I just do like this :
void getIdBranch()
{
if ("System.Data.DataRowView" == tbDropBranch.SelectedValue.ToString())
{
return;
}
else
{
DataTable dtPanel = dataBinding._valuePanel(Convert.ToInt32(tbDropBranch.SelectedValue.ToString()));
tbDropPanel.DataSource = new BindingSource(dtPanel, null);
tbDropPanel.DisplayMember = "panelName";
tbDropPanel.ValueMember = "panelID";
}
}
Thank to those who helped.. :)
tbDropBranch.SelectedValue.ToString()?dataBinding._valuePanel?