我在我的网站上发现了一个错误,但我似乎找不到解决方案。我正在动态生成控件,其中两个是 RadDatePicker 和 RadTimePicker。当页面上发生不同的事件时,我会在生成控件后在真假之间更改控件的可见性(主要基于页面是处于“编辑”模式还是查看模式)。但是,在控件可见的第一个实例之后,控件将失去其样式。请参阅下面的屏幕截图:
如果有人有任何建议或建议,那就太好了。谢谢
更新:这是所要求的代码
这隐藏和显示控件(只需更改真/假)
for (int i = 0; i < customProperties.Rows.Count; i++)
{
customProperties.FindControl("CustomControl" + (i + 1).ToString()).Visible = false;
customProperties.FindControl("lblCustomControl" + (i + 1).ToString()).Visible = true;
Type aType = customProperties.FindControl("CustomControl" + (i + 1).ToString()).GetType();
if (aType.Name == "RadBinaryImage")
customProperties.FindControl("CustomControl" + (i + 1).ToString() + "_btn").Visible = false;
}
所以基本上它在 htmltable (customProperties) 中搜索控件并更改可见性
这是生成控件的地方:
case DynamicFieldTypeEnum.Date:
RadDatePicker dp = new RadDatePicker();
dp = currentValues as RadDatePicker;
if (dp.SelectedDate == null)
customProperty.Text = "Not Specified";
else
customProperty.Text = dp.SelectedDate.Value.ToString(dp.DateInput.DateFormat);
dp.ID = "CustomControl" + (position + 1).ToString();
newControls[0] = customProperty;
newControls[1] = dp;
break;
case DynamicFieldTypeEnum.Time:
RadTimePicker tp = new RadTimePicker();
tp = currentValues as RadTimePicker;
if (tp.SelectedDate == null)
customProperty.Text = "Not Specified";
else
customProperty.Text = tp.SelectedDate.Value.ToString(tp.DateInput.DateFormat);
tp.ID = "CustomControl" + (position + 1).ToString();
newControls[0] = customProperty;
newControls[1] = tp;
break;
这是在给定对象定义然后返回控件数组的方法中。控件数组中的第一个值是“查看”模式的标签,第二个控件是“编辑”模式的控件。
然后将该数组传递给不同的方法,该方法将控件放置在表格单元格中,该单元格放置在表格行中,然后放置在表格“customProperties”中