Professional Web Applications Themes

update row with null numeric or datetime dataset cell values in a datagrid - ASP.NET

I keep getting the, now, dreaded "System.FormatException: String was not recognized as a valid DateTime" error when updating a datagrid row that has null (DBnull) cell values. Same sort of "System:FormatException" error for numeric columns. For text columns, providing a defaultValue in the SQL Server (2000) got rid of the error; however, supplying defaultValues seems to have no affect with numeric or datetime columns. I noticed that the webform dataset Properties say that the defaultValue for all columns is DBnull, though this is NOT the case in the SQL Server database source table. Before the error line in my Update ...

  1. #1

    Default update row with null numeric or datetime dataset cell values in a datagrid

    I keep getting the, now, dreaded "System.FormatException: String was not recognized as a valid DateTime" error when updating a datagrid row that has null (DBnull) cell values. Same sort of "System:FormatException" error for numeric columns.

    For text columns, providing a defaultValue in the SQL Server (2000) got rid of the error; however, supplying defaultValues seems to have no affect with numeric or datetime columns.

    I noticed that the webform dataset Properties say that the defaultValue for all columns is DBnull, though this is NOT the case in the SQL Server database source table.

    Before the error line in my Update routine, I tried:
    wfdsContacts.Contacts.LastContactDate.Column.Defau ltValue = "1/1/1900";

    .... without getting rid of the error.

    Since I couldn't find any examples of how to handle updating webform datagrid dataset rows with null cell numeric or datetime values, could someone shed some light on how to approach this?

    thanks,

    Mike


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.543 / Virus Database: 337 - Release Date: 11/21/2003

    Michael Coughlin Guest

  2. #2

    Default Re: update row with null numeric or datetime dataset cell values in a datagrid

    I stumbled upon the following ... which worked! I inserted the defaultValue assignment after the default credentials assignment and ... before the call to merge the web service dataset into the web-form dataset.
    --------------------------------------------------------
    // assign default credentials to the web service instance

    wsi.Credentials = System.Net.CredentialCache.DefaultCredentials;

    // Set any necessary default values, prior to

    // merging web-service dataset into web-form dataset (wfds...).

    wfdsContacts.Contacts.LastContactDateColumn.Defaul tValue = "1/1/1900";

    // populate the dataset by calling the GetTable function

    wfdsContacts.Merge(wsi.GetContacts());

    -----------------------------------------

    No more System.FormatException errors!

    Thanks, anyway ...

    /Mike

    ****************************

    "Michael Coughlin" <noSpamanywhere.net> wrote in message news:%23BNBNE5uDHA.2440TK2MSFTNGP12.phx.gbl...
    I keep getting the, now, dreaded "System.FormatException: String was not recognized as a valid DateTime" error when updating a datagrid row that has null (DBnull) cell values. Same sort of "System:FormatException" error for numeric columns.

    For text columns, providing a defaultValue in the SQL Server (2000) got rid of the error; however, supplying defaultValues seems to have no affect with numeric or datetime columns.

    I noticed that the webform dataset Properties say that the defaultValue for all columns is DBnull, though this is NOT the case in the SQL Server database source table.

    Before the error line in my Update routine, I tried:
    wfdsContacts.Contacts.LastContactDate.Column.Defau ltValue = "1/1/1900";

    ... without getting rid of the error.

    Since I couldn't find any examples of how to handle updating webform datagrid dataset rows with null cell numeric or datetime values, could someone shed some light on how to approach this?

    thanks,

    Mike


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.543 / Virus Database: 337 - Release Date: 11/21/2003

    Michael Coughlin Guest

Similar Threads

  1. DataSet/DataGrid/Null values
    By jpryz in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: June 26th, 05:39 PM
  2. Unable get Boolean and Numeric values from XLS into Dataset and Datagrid
    By vighnesh in forum ASP.NET Data Grid Control
    Replies: 3
    Last Post: August 4th, 02:16 PM
  3. DataSet not passing String values to DataGrid
    By vialis in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: March 28th, 05:04 AM
  4. Null values in a datagrid checkbox column
    By Rock in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: December 3rd, 02:26 AM
  5. Null values in typed dataset
    By Ola Ekelund in forum ASP.NET Web Services
    Replies: 0
    Last Post: November 13th, 03:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139