473,729 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Databound DateTime field question

Hello all:

I have a FormView that has it's DataSourceID set to a SqlDataSource
that uses stored procedures for it's select, update, insert, and
delete. I want the FormView to have an "autosave" feature, so based on
certain intervals or user interactions I call the

FormView.Update Item(false); function in my C# code behind.

My problem is that a TextBox that I have in my FormView is bound to a
DateTime column in the database, and if no value is in the TextBox
then a date of Jan. 1, 1900 is saved to the database. The column
accepts null values. How can I get my TextBoxes that are bound to
DateTime columns save null when no value has been entered?

Any help or leads is greatly welcomed! Thank you in advance.

Sep 11 '07 #1
2 2174
ed
Hi justin,

Assuming that your underlying SQL datatype is smalldatetime (1/1/1900
is the smalldatetime type's minimum value) it looks like the value
from the textbox is being treated as blank, not null. You're going to
have to jump in somewhere and swap that blank for a null when you
update.

Does that give you enough to work with? If not, I'd recommend posting
your function and/or your SP's -- perhaps even the non-default
properties to the bound textbox.

Hope this helps,
Ed

On Sep 11, 1:47 pm, justin <justin.cre...@ gmail.comwrote:
Hello all:

I have a FormView that has it's DataSourceID set to a SqlDataSource
that uses stored procedures for it's select, update, insert, and
delete. I want the FormView to have an "autosave" feature, so based on
certain intervals or user interactions I call the

FormView.Update Item(false); function in my C# code behind.

My problem is that a TextBox that I have in my FormView is bound to a
DateTime column in the database, and if no value is in the TextBox
then a date of Jan. 1, 1900 is saved to the database. The column
accepts null values. How can I get my TextBoxes that are bound to
DateTime columns save null when no value has been entered?

Any help or leads is greatly welcomed! Thank you in advance.

Sep 11 '07 #2
On Sep 11, 2:45 pm, e...@lakenine.c om wrote:
Hi justin,

Assuming that your underlying SQL datatype is smalldatetime (1/1/1900
is the smalldatetime type's minimum value) it looks like the value
from the textbox is being treated as blank, not null. You're going to
have to jump in somewhere and swap that blank for a null when you
update.

Does that give you enough to work with? If not, I'd recommend posting
your function and/or your SP's -- perhaps even the non-default
properties to the bound textbox.

Hope this helps,
Ed

On Sep 11, 1:47 pm, justin <justin.cre...@ gmail.comwrote:
Hello all:
I have a FormView that has it's DataSourceID set to a SqlDataSource
that uses stored procedures for it's select, update, insert, and
delete. I want the FormView to have an "autosave" feature, so based on
certain intervals or user interactions I call the
FormView.Update Item(false); function in my C# code behind.
My problem is that a TextBox that I have in my FormView is bound to a
DateTime column in the database, and if no value is in the TextBox
then a date of Jan. 1, 1900 is saved to the database. The column
accepts null values. How can I get my TextBoxes that are bound to
DateTime columns save null when no value has been entered?
Any help or leads is greatly welcomed! Thank you in advance.
That makes sense, but I guess I'm not sure how to "jump in somewhere".
I don't see any events for the TextBox that would happen before
updating the database.

I can think of a few ways to replace the DateTime value if I wasn't
using the SqlDataSource and the update StoredProcedure , but what I'm
really looking for is something that will work with the DataSource. If
there was a default value for the TextBox or an event that fired
before an update on just the TextBox that would work, but I don't see
anything like that.

Sep 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1832
by: Keith | last post by:
I am fairly new to SQL so sorry if this is a really dumb question. I have a small (still) SQL database, which I am trying to query from an ASP page. The field I am querying is of DATETIME data type, and is populated automatically using the GetDate() function as a default value. When I try and search on this field, using a date/time in the format dd/mm/yyyy hh:mm:ss as the search criteria, it fails with the following
6
1817
by: Carl | last post by:
Hi, to be use with SQL server database 1- From window form textbox object From this assignement, txtTOTAL.Text="0.00m"; How do you convert back to decimal type ? How do you assign a default datetime value to it ? How do you convert back the text enter by user into datetime ?
44
16981
by: Frank Rizzo | last post by:
Any ideas?
8
5888
by: bienwell | last post by:
Hi, I have a problem of displaying data bound by a datalist control. In my table, I have a field Start_date which has Short Date data type. I tried to update this field by Current Date. After that, I display End_Date on the DataList control. The output looks like 3/18/2005 12:00:00 AM . I'd like to format data for this field to be 3/18/2005. Please help me. Thanks in advance....
4
4601
by: kd | last post by:
Hi All, I have a datetime column in a table on the SQL database. I need to insert values into the datetime column from vb.net code. Here is my code: dim nameval, str, qry as string nameval = "abc" str = "2005/03/16 14:20" qry = "insert into tab1(name,dateval) values(" & "'" & nameval & "'," & "'" str & "')" ....
0
1503
by: Benny Dein | last post by:
Hi A newbie question regarding using update function on sqldataadapter: I have created a connection, a dataadapter and a dataset on my webform. I have put a texbox on my webform to show a value from a certain field on a selected record. The textbox is databound to my datatable and shows as wanted the value in the sql selected row.
5
2599
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field (MSSQL Server) it worked on my test machine. If I run the same application on another machine with different regional settings is not working. I tried with date_default_timezone_set to change timezone but is not changing. After...
6
1413
by: =?Utf-8?B?QmVuLg==?= | last post by:
Hi, I'm more of a windows programmer than ASP and I've having a little difficulty in ASP.Net (framework 2.0) - VB.net I have a datagrid on an aspx page and the html is building the display in a table row by row. A sample row being <tr> <td>Comment:</td>
9
2425
by: Kyote | last post by:
I have a textbox that is databound to a table in an access database. The field only contains month/day/year but my databound textbox is also showing a time. Is there any way to prevent it from doing this? --- Kyote
0
9427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9284
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9202
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9148
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4528
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.