DataSource Controls :: Using Null Date Values And String Was Not Recognized As A Valid DateTime Error?
Jul 5, 2010
I am very new to ASP .NET and am getting above error when trying to insert a new record into a SQL database. I have turned on Option Explicit On so the default date of 01/01/1900 does not get assigned to this field automatically. Since most of the people in the database will not have a date of death, I need to have "blank" deathDate. When I run the stored procedure within SQL and choose pass null value, the Insert Procedure works fine. When I attach to Web Form, however, I get String was not recognized as a valid DateTime error. How can I set it so Null values are accepted into this date field.
I am having trouble formatting the date on a textbox I get the error above if I don't enter the date in MM/DD/YY format in the textbox. I am also using this in a FormView so I can't format it or don't know how to in the code behind so if there is a way to format it in design view that would be preferable. Does anyone have any ideas on how I would do any of this.
bolded part for extracting date in a label( lblRequestDate). but for some records it is not working and for some it is working. I want to make it like if any record doesnt have any value then it should shows in label lblRequestDate blank
how to do that, even I am not understanding if it work for some records then it should work for all records where as all records having NULL value.
I am developing web application using csharp on visual studio 2008. I am loading the data from Microsoft Excel to datagrid. But when I want to check the date in a given column and getting the error String was not recognized as a valid DateTime . How can I solve this problem? The code I am using is below.
I'm using AJAX calendar control in a tabcontainer, The date is being captrued in the following format: "3/11/2010" (MM/DD/YYYY).And on code behind i'm converting the above value to datetime like this, Everytime i'm getting the error "String was not recognized as a valid datetime".Can anyone please help me out fixing this problem..
The error points to this line: DateTime tmpDate = Convert.ToDateTime(lblCalendarDate.Text).AddDays(-7);
I know it will be something to do with I have the date as a string in one method and the date as date in another method but I don't know how to rectify this seeing as I'm knew to ASP.Net & C#. Here is the code:
I am using calender extender for 2 textboxes(txtstartdate,txtenddate) and have set the format as "dd/MM/yyyy". At the txtenddate textchanged event i am calculating no of days to diplay in txtduration.text..I am getting format exception like this:
I have a problem in my application. I have deployed application on server. i have a string in dd/mm/yyyy format. to which when i am trying to parse in datetime it is working fine on my server when i am working locally on server. but when i am trying it remotely(client) it is giving exception saying string is not recognized as valid datetime format. This is how i am trying the code.
I have a page that has been working for sometime and now getting this error..
String was not recognized as a valid Boolean.
Im was working on a How-To document of the pages for our VP and now i cant get to page 2 to continue the document.
I have recently added 2 new radiobuttonlists(rel and relst) and im sure its one of them thats causing the issue. But sicne i cant debug not sure which one is failing. Here is my insert code and the error is occuring on the Line 376:
The fields for the radiobuttons are all setup as BIT in SQL. They all have default values of 0. They are all setup NOT TO ALLOW NULLS.