2

1) When SqlParameter.IsNullable is set to true, received null value is converted to DBNull.Value and sent to database. Thus I would assume setting IsNullable to true only makes sense when GridView’s Parameter.ConvertEmptyStringToNull is also set to true?

2) Both GridView’s and ObjectDataSource’s parameters have a ConvertEmptyStringToNull property. But is there ever a situation where ( when trying to update data source ):

• where we should set GridView’s Parameter.ConvertEmptyStringToNull to true, but then set ObjectDataSource’s Parameter.ConvertEmptyStringToNull to false?!

• or where we should set GridView’s Parameter.ConvertEmptyStringToNull to true, but SqlDataSource’s SqlParameter.IsNullable to false?

Michael Kniskern
  • 24,792
  • 68
  • 164
  • 231
SourceC
  • 3,829
  • 8
  • 50
  • 75

2 Answers2

0

Ans : 1: When SqlParameter.IsNullable is set to true, received null value is converted to DBNull.Value and sent to database. Thus I would assume setting IsNullable to true only makes sense when GridView’s Parameter.ConvertEmptyStringToNull is also set to true? - simply yes

0

The responses in general are "NO" to all your questions, because not always there is a DataGrid, which is not the only way to show data and or get an input from the user.

If your user interface provides data in another way (e.g. DetailView, FromView, hand-made-window-or-page, etc...), or you have not UI at all, and your data come from another source, you may have to deal with IsNullable and/or ConvertEmptyStringToNull properties independently from a DataGrid that does not exists!

IsNullable in particular, when you are calling stored procedures, should match the sp's definition of the parameter.

BertuPG
  • 653
  • 4
  • 6