加载空字符串和 Silverlight 4
我维护一个 Silverlight 4 应用程序。当我不在办公室时,数据库结构发生了更改,删除了一个表,并将其字段合并到另一个现有表中。现在,在创建新项目并进入其“摘要”屏幕后,我收到以下错误:
“值不能为空。参数名称:文本 在 System.Windows.Controls.TextBox.set_Text(String value)”,
这种情况仅发生在新创建的条目中,而不是下一个屏幕上的信息完整的旧条目中(数据从 Excel 电子表格转换并加载到数据库中)。因此,我缩小了范围:用于创建新记录的子窗口不包含添加到表中的所有字段,因为创建记录时某些信息不可用。 Google 搜索发现,空字符串不能在 Silverlight 中传递。
摘要屏幕通过 ddsSummaryLoadedData 域服务加载。如果我不包含“新”字段,则不会加载现有条目的值,但新条目不会导致错误。如果我确实包含它们,旧条目会正确加载,但新条目会出现上述错误。
是否有解决方法可以创建空字段,直到需要它们为止,但仍然加载数据(如果存在)(对于较旧的条目)?或者子窗口需要重新设计吗?我是 Silverlight 新手,还有很多东西需要学习!
I maintain a Silverlight 4 application. While I was out of the office, the database structure was changed and a table was dropped and its fields combined into another existing table. Now, I’m receiving the following error after I create a new item and proceed to its "summary" screen:
“Value cannot be null. Parameter name: Text
At System.Windows.Controls.TextBox.set_Text(String value)”
This only happens with newly created entries, not older entries where the information on the next screen is complete (data was converted from an Excel spreadsheet and loaded into the database). So, I’ve narrowed it down this: the child window that is used to create a new record doesn’t have all the fields that were added to the table because some of the information isn’t available when the record is created. A Google search turned up that null strings can’t be passed in Silverlight.
The Summary screen is loaded via ddsSummaryLoadedData domain service. If I don’t include the “new” fields, then the values aren’t loaded for existing entries, but new entries don’t cause an error. If I do include them, older entries load correctly but new ones give the above error.
Is there a workaround to create the empty fields until they’re needed, but still load data if it exists (for older entries)? Or does the child window need to be redesigned? I’m new to Silverlight and still have so much to learn!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您没有使用 Bindings 来渲染视图,否则 null 值将得到妥善处理,因此,如果您在代码中手动设置 Text 属性,请使用级联运算符来验证您没有提交 null 值。
It doesn't look like you're using Bindings to render your view otherwise null values will be handled gracefully, so if you are setting the Text property manually in code, use the cascading operator to verify you are not submitting a null value.