我使用以下内容填充组合框,但我将当前实体值设置为下拉列表中的内容,并通过树视图中选择的行进行更改。
dpParentId.DisplayMember = "Value";
dpParentId.ValueMember = "Key";
dpParentId.DataSource = cmsContext.GetAllCategoriesFromLookupDropDown();
public Dictionary<int, string> GetAllCategoriesFromLookupDropDown()
{
Dictionary<int,string> list = new Dictionary<int, string>();
try
{ //for a common table to work i neaded some way to have it that their a blank entry so zero cant be so i have choosen 3
foreach (CustomLookup cs in cmsEntities.CustomLookups.Where(a=> a.LookupType==1))
list.Add(Convert.ToInt32(cs.ID), cs.Description);
}
catch (Exception ex)
{
throw new EntityContextException("GetAllCategoriesFromLookupDropDown failed.", ex);
}
return list;
}
然后在我的treeview selectedchanged事件中,我有以下
private void rgStandardLookup_SelectionChanged(object sender, System.EventArgs e)
{
currentEntity = null;
try
{
bool oldDataChanged = dataChanged;
if (rgStandardLookup.SelectedRows.Count > 0)
{
currentEntity = rgStandardLookup.SelectedRows[0].DataBoundItem as CustomLookup;
txtCode.Text = currentEntity.Code.ToString();
txtDescription.Text = currentEntity.Description;
chkParent.Checked = Convert.ToBoolean(currentEntity.isParent) ? true : false;
LookupType = Convert.ToInt16(currentEntity.LookupType);
dpParentId.SelectedValue = Convert.ToInt16(currentEntity.ParentLookUpID);
}
}
catch (Exception ex)
{
ExceptionBox.Show("An error occurred in the rgStandardLookup_SelectionChanged", ex);
}
}
private void dpParentId_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
try
{
if (currentEntity != null)
{ // currentEntity.ParentLookUpID = Convert.ToInt16(dpParentId.SelectedValue);
}
}
catch (Exception ex)
{
ExceptionBox.Show("An error occurred in the dpParentId_SelectedIndexChanged", ex);
}
}
问题在于根据数据库中的值
作为第一项保持不变ID代码名称描述ParentLookUpID LookupType isParent 15 0 NULL 15 1 NULL 2 1 .NET .NET NULL 1 1 3 2 Foxpro Foxpro 2 1 0 4 3 HTML HTML NULL 1 1 5 4 SQL SQL NULL 1 1 6 5 PAMS Pams NULL 1 1 7 6 C#C#NULL 1 1 8 7 VB.NET VB.NET NULL 1 1 14 8 NULL测试NULL NULL NULL
所以在下拉列表中它应该显示2为foxpro但不是它的停留数15?我的主要问题是,当我尝试设置所选的值时,它不会在下拉列表中重新计算它只是坐下来记录15空白的行是空行
答案 0 :(得分:0)
您可能必须使用委托来同步两个保管箱