【问题标题】:I assume SqlParameter.IsNullable only makes sense when…?我假设 SqlParameter.IsNullable 仅在……时才有意义?
【发布时间】:2009-06-02 21:03:19
【问题描述】:

1) 当SqlParameter.IsNullable 设置为true 时,接收到的null 值转换为DBNull.Value 并发送到数据库。因此我假设将IsNullable 设置为true 仅在GridView 的Parameter.ConvertEmptyStringToNull 也设置为true 时才有意义?

2) GridView 和 ObjectDataSource 的参数都有一个ConvertEmptyStringToNull 属性。但是是否有过这种情况(尝试更新数据源时):

• 我们应该将GridView 的Parameter.ConvertEmptyStringToNull 设置为true,然后将ObjectDataSource 的Parameter.ConvertEmptyStringToNull 设置为false?!

• 或者我们应该将 GridView 的Parameter.ConvertEmptyStringToNull 设置为true,但将SqlDataSource 的SqlParameter.IsNullable 设置为false

【问题讨论】:

    标签: c# .net asp.net gridview objectdatasource


    【解决方案1】:

    Ans : 1: 当SqlParameter.IsNullable 设置为true 时,接收到的null 值转换为DBNull.Value 并发送到数据库。因此,我假设将 IsNullable 设置为 true 仅在 GridView 的 Parameter.ConvertEmptyStringToNull 也设置为 true 时才有意义? - 是的

    【讨论】:

      【解决方案2】:

      对所有问题的回答通常都是“否”,因为并非总是存在 DataGrid,这不是显示数据和/或从用户那里获取输入的唯一方法。

      如果您的用户界面以其他方式提供数据(例如 DetailView、FromView、手工制作的窗口或页面等),或者您根本没有 UI,并且您的数据来自其他来源,您可能必须独立于不存在的 DataGrid 处理 IsNullable 和/或 ConvertEmptyStringToNull 属性!

      IsNullable尤其是在调用存储过程的时候,应该和sp对参数的定义相匹配。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-07-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-19
        • 1970-01-01
        • 2013-10-07
        • 1970-01-01
        相关资源
        最近更新 更多