LINQ to SQL和数据绑定 [英] LinQ To SQL And DataBinding

查看:128
本文介绍了LINQ to SQL和数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格(的WinForms)与绑定到数据源文本框。

I have a form (WinForms) with a TextBox Binded to a Datasource.

数据源是LINQ to SQL的查询返回一个单一的行。 该行只有一个申请,为varchar(100),不能为空。

The datasource is a LinQ To SQL query returning one single row. This row have only one filed, varchar(100), not nullable.

我的问题是,如果用户去外地(含重点),他不能离开,而他插入数据,因为该数据字段不能接受空。

My problem is that if the user go to the field (with the focus), he can't exit while he insert a data because the data field cannot accept null.

这是可能的一个TextBox绑定到字段不能为空,而不是验证每个单独的申请,但整个造型?

It is possible to bind a TextBox to a field not nullable and not validate each single filed but the entire form ?

感谢您!

推荐答案

您可以绑定单向的,但你必须当用户点击保存或手动更新L2S实体OK。

You can bind one-way, but then you'll have to update the L2S entity manually when the user clicks "save" or "ok."

您也可以提供一个默认值,所以用户可以通过文本框选项卡,但你可能会看到默认值出现在你的数据库中。

You could also provide a default value, so the user can tab through the textbox, but you might see that default value appearing in your database.

这篇关于LINQ to SQL和数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆