【发布时间】:2015-07-20 11:07:49
【问题描述】:
我正在使用 Windows CE,我的界面及其内容是根据所选数据库动态生成的。
组合框从数据库(description table) 中获取值并将选定的值(value table) 保存到不同的表中。插入过程中没有问题。组合框工作得很好。
但是,当我尝试检索插入的数据时,组合框无法显示插入的值。有什么功能可以解决这个问题吗?
selectedDescription = dr["value"].ToString().Split(',').ToList<string>();
if (dr["type"].ToString() == "multiple") {
ComboBox combo = new ComboBox();
combo.DataSource = selectedDescription;
combo.Width = 60;
combo.Height = 27;
combo.Location = new Point(currentX, currentY);
combo.Tag = Id;
//如果 getVal 不为空(意味着为此特定组合选择/插入了值),则 combo.DataSource 应该是插入的值。
但是,当我分配combo.Datasource = ds["val"].ToString(); 时,我无法在设备上打开此模块。然后我尝试了combo.SelectedValue,但组合框改为显示selectedDescription。
if (getVal != null) {
foreach (DataRow ds in getVal.Tables[0].Rows) {
if (Convert.ToInt32(ds["descId"].ToString()) == combo.Tag)
{
combo.SelectedValue = ds["val"].ToString();
}
【问题讨论】:
-
看来你必须通过这样写来控制页面回发: if (Page.IsPostBack) { return;因为回发后,会看到ComboBox的空白数据。
-
是windows form还是webform相关的问题?
-
你能演示/修改我的代码@hqtunes.com吗?
-
这是windows窗体相关的@Mou
-
再次简要告诉我问题......所以我可以试试!