.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Time in TextBox passed with current date to ObjectDataSource

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

Dear All.

I am developping an ASP.NET Web-Application with Visual Studio 2010 and .Net Framework 4.0.
In one of the pages I have a gridview with template fields bound to an ObjectDataSource (ConflictDetection is set to "CompareAllValues").

In one of the TextBoxes, the user can view/edit a time value (Bind("Fieldname", "{0:HH:mm"}, datetime datatype in SQL Server). The problem is that the value is passed to the DataSource not only as a time (of date #1/1/1# or another fix "root"-date) but as the time of the current date. Since this also applies to the original values, any update operation fails, because the Where-Clause sent to SQL Server tries to find a record with the time of the current day which does not exist.

I would like to add the time entered to a fix root date (#12/30/1899# like in MS Access). Is this at all possible and can someone please tell me, how to accomplish this? Thanks in advance.

Kind Regards


View Complete Post

More Related Resource Links

How do I populate a Textbox with the current system date and time?

Hello, all! First I am a complete newbie and I have a project that I need help with. I am building a Windows form application to keep track of servers and their last maintenence date. I have a simple one table SQL Express database (empty). One of my rows is set up to store the date and time. But first, I need to know how to auto populate the system date and time to a TextBox control everytime someone opens the application. I have tried using the System.DateTime method in the Textbox event properties as a string but I am doing something wrong. Thanks in advance for your help and guidence!

How to insert the Current date and time in to SQL Table..

Hello Members,              I have create the table as per the following ..create table company(  empname varchar(30),  empid int,  joindate smalldatetime)I tried,insert into table values('Kumar',202, ??????)I want to insert Current date and time into table Company.....Please give me the solution...Thanks.. 

how to get the current date and time using sharepoint designer workflows

hi, how to send an email using sharepoint designer workflow when an item equals to end time. How to get the current date and time.I am able to capture the date but not the time  the time is showing as 12:00:00 AM. First i have create an variable  and storing the date and time in that variable and i am comparing the variable value with end time. If both are equal then i want to send an mail to attendees

Time added to Detailsview TextBox Date only field


Does anyone know why a time stamp is added to a textbox field that is bound to a SQL 2008 date datatype field?

I can view the data in the database and, as expected, it only contains a date. When I bind the textbox to the db field it tacks the time '12:00:00 AM' to the end of the date?


Auto Populate current date & time in the New form



I have requirement where I want the current date and time in the newform opened by users. I can get the current date with Today's Date option. But not able to find the time option. Is there a possibility with SPD. Tried using button option to activate a formula to the textbox value so the user can jus click the button to get the current time and date. but facing problem in that.  Kindly advice.



Move up a time hierarchy from current date to return a set of quarters


I have this calculated set to return the previous 3 months.  How do I rewrite to get the last 3 quarters? 



(3,strtomember("[Date].[Month].&[" + Format(Now(),"yyyy-MM") + "-01T00:00:00]").prevmember)


How to receive current date and time from exchange server when ISA/TMG is in between ?


I am reading Exchange resource mailbox using .Net CF C#. For WebDAV communicatoin, I have used a third party API and It's working fine. For EWS I have developed my own library. But I could  not find the way for receiving current time form exchange server.

To achieve this I have used following code:



private DateTime getCurrentServerTime(

Date and Time Functions in SQLSERVER

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

1 DATEPART Function
2 DATENAME Function
3 DAY, MONTH, and YEAR Functions
5 DATEADD Functions
6 DATEDIFF Function
7 More SQL Server Functions

Data Types - Date and Time in SqlServer

Date and time values can be stored with either the DATETIME or SMALLDATETIME data type. The difference between the two is that SMALLDATETIME supports a smaller range of dates and does not give the same level of precision when accounting for time. The DATETIME data type can hold values from January 1st of 1753 to December 31st of 9999. The time is stored to the 1 three hundredths of a second and each value takes up 8 bytes of storage. The SMALLDATETIME data type can hold values between January 1st 1900 and June 6th of 2079. The time is tracked to the minute and each value takes up 4 bytes of storage. The majority of business applications can live happily with SMALLDATETIME, however, if you are in an environment where each second matters or you need to make estimates to the distant future (or past) then you have to resort to DATETIME. If you fail to specify the time when inserting a value into a DATETIME or SMALLDATETIME column, a default of midnight is used. If you fail to specify the date portion the default of January 1, 1900 is used.

Built-in Functions - Date and Time Functions

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

Essential SQL Server Date, Time and DateTime Functions

The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all.

Date/Time Conversions Using SQL Server

There are many instances when dates and times don't show up at your doorstep in the format you'd like it to be, nor does the output of a query fit the needs of the people viewing it. One option is to format the data in the application itself. Another option is to use the built-in functions SQL Server provides to format the date string for you.

Date and Time Data Types and Functions

The following sections in this topic provide an overview of all Transact-SQL date and time data types and functions. For information and examples that are common to date and time data types and functions

Convert Update Date/Time to VB.NET



I was wondering if someone could convert this into VB.NET for me.  I'm not a PHP pro and not entirely sure what's happening here nor do I know how to get this to display the same way.

The new field is within a DetailsView, so you can give me example code as well, I'll greatly appreciate it.

Thanks.. -Jeff

PHP Code:

function updFormat($tStamp) {
	$tsTime = (strftime('%I', $tStamp) + 0) . strftime(':%M %p', $tStamp);
	// 86400 == # of seconds in a day
	$tsDays = floor($tStamp / 86400);
	$nowDays = floor(time() / 86400);
	if ($tsDays == $nowDays) $updTime = "Today at $tsTime";
	elseif ($tsDays == $nowDays - 1) $updTime = "Yesterday at $tsTime";
	else $updTime = strftime('%b ', $tStamp) . (strftime('%d', $tStamp) + 0) . strftime(', %Y' , $tStamp);

	return $updTime;
<asp:DetailsView ID="dtv_LastUpdated" runat="server" Width="100%" 
    AutoGenerateRows="False" DataSourceID="ods_MVPParcelUpdate" 
    CellPadding="1" CellSpacing="1" GridLines="None">
        <asp:BoundField DataField="Update_time" HeaderText="Parcel Data:" 

Enter the date on the WPF DatePicker input textbox instead

When i type in the date on the date picker and check it on an lostfocus event and i try to read the text or selecteddate its blank?  Am i missing something.  I assumed typing in 5/11/2010 on the input box would either show up on the controls Text or the SelectedDate, but i may be missing something   Thanks

AjaxControlToolkit.CalendarExtender - highlight current date

I have used AjaxControlToolkit.CalendarExtender for calendar in my project.but anyhow I am unable to highlight current date  in calendar control.(Note: Current date I mean is today's date and not the selected date.)e.g.( If today is 15th August 2010, and I have selected 24 August 2010. then when I press calendar icon, I should see 15 august highlighted with different look or same as selected date 24 highlighted in August month of 2010 page in calendar popup.)Please guide me to accomplish the taskThanks in advance for support.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend