GridView - Editing a column only displaying the Time part of a date time field

Hello,

I have a column on a GridView that is formatted to only display the time part of a date time field. However, whenever I edit the cell value the Date part of the field is changed to today's date. The way I've got round this is to implement the CellValueChanged event. Is there a better way of doing this? Code is below.

        private void dgTimeSlots_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            int col = e.ColumnIndex;
            int row = e.RowIndex;
            if (col >= 0 && row >= 0)
            {
	// the correct date
                DateTime selectedDate = (DateTime)comboDates.SelectedValue;
                if (col == startTimeDataGridViewTextBoxColumn.Index)
                {
                    DateTime changedDateTime = (DateTime)dgTimeSlots.Rows[row].Cells[col].Value;
                    ((Configurations.TimeSlot)dgTimeSlots.Rows[row].DataBoundItem).StartTime = (selectedDate + changedDateTime.TimeOfDay);
                }
                else if (col == endTimeDataGridViewTextBoxColumn.Index)
                {
                    DateTime changedDateTime = (DateTime)dgTimeSlots.Rows[row].Cells[col].Value;
                    ((Configurations.TimeSlot)dgTimeSlots.Rows[row].DataBoundItem).EndTime = (selectedDate + changedDateTime.TimeOfDay);
                }
            }
        }
Thanks
Sidharth
0
Sidharth
10/24/2006 11:37:44 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
983 Views

Similar Articles

[PageSpeed] 48

:) Sorry - wrong forum!
0
Sidharth
10/24/2006 11:48:28 AM
Reply:

Similar Artilces:

Date / Time Field
PB 7.0.3 I have an application that records patient encounters, treatments and referrals for an Emergency Department within a hospital. Each encounter records time to nurse and time to physician - these fields are of datetime format. This application is for statistical purposes only and therefore is not real time (unit clerks key in the necessary data throughout the day). Here is a senerio... Patient A enters the ED and the date / time of encounter is recorded. The date and time that the triage nurse first assesses the patient is recorded (time to nurse) The date and time that th...

remove time part from a date/time field value
How does one remove or avoid the time part from a date/time field value. For example store 12/12/2006 instead of 12/12/2006 12:00:00 Am --------------------------------------------------No Project Too Eazy.-------------------------------------------------- You can use one of the appropriate Standard DateTime Format Strings such as d or D.Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! You should be able to use DateTime dt = DateTime.Now dt.ToString("d")  //this will format as short date time FYI: If you want to do it at the query ...

just Time or date portion of a date/time field
Good Day, From a DateTime data column how do I get just a Time portin or just a date portion of data to be displayed. i.e from 11/6/2003 10:03:20 AM I need to display date and time seperately in my data display page. Thanks Regards, In code you could use Dim dt as System.Date Dim day, month, year as integer day = dt.Day month= dt.Month year = dt.Year This also works with DateTime In SQL you could use DATEPART(<datepart>,<datetime>) where <datepart> is the abbreviations mentioned in post 385301 and <datetime> is a...

date/time or date and time
I am setting up an SQL database and I will need to get differences in dates. For example I have a start date, start time, completion date and completion time and I want to get the difference between the start and completion. Would it be better to have one field with both date and time in it, or better to have a date field and a time field? Even though I have already started setting up the tables with seperate fields for date and time I am now leaning toward one field with date/time in it. (Only because that is the way I had to do it when setting up an Excel spreadsheet for a similar ta...

Date entered...add time value to make date/time field
Windows XP Professional InfoMaker v 9.0.2 Build 7509 Our database contains a date/time stamp for when a specific activity happens to each shipment. I would like the users to be able to simply enter a date for a specific work day. I need to get a list of shipments where the time of one activity occurred on the entered date prior to 9:20. How can I create a computed field that will basically concatenate/amend the entered date with 9:20 that will later be used for criteria in returning rows? Thanks in advance for any help you can provide! Rita Palazzi Senior Engineer /...

just Time or date portion of date/time field: SOMEBODY PLS
Good Day, From a DateTime data column how do I get just a Time portin or just a date portion of data to be displayed. i.e from 11/6/2003 10:03:20 AM I need to display date and time seperately in my data display page. Thanks Regards, When you pull in a SQL datetime column value into your .NET code, it is usually cast to a .NET DateTime type... something like this: System.DateTime TheDateAndTime = (System.DateTime)someDataReader["MySQLDateColumn"] Then you can use a variety of .NET methods included in the DateTime class to convert to a strin...

hide time in date/time field
hi. i have code : objConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\database\tfasim.mdb;")   if rblLTorGT.SelectedValue = "Id" then      strSQLQuery = "SELECT Date_T as  [date] ,name FROM table " & _     ORDER BY " & ddlSortBy.SelectedItem.Value.ToString() & ddlSortOrder.SelectedItem.Value.ToString()   objCommand = New OleDbCommand(strSQLQuery, objConnection)   objConnection.Open()    objData...

Update Only the Time in a date time field
Hi,i have a table having a datatime field and on a datagrid I need only to display and update the time part. I'm using select CONVERT(CHAR(8), JobStartTime, 8) AS StartTime from table to get the date. What is  the best way to write the update command . What woul dbe the best approch.   Regards, Vijay  1. Instate of doing formatting in the SQL, Try to do that is the DataGrid with FormatString. 2. To Update the Database , you can do that in two ways.    a. Either go for Store Procudure. Send the TIME you want to set for record. Your SP should some ...

Is there a simply way to display the time in another time zone by the time in a zone time?
Now local time is 2007-07-26 16:32, I hope to display US time of the time, maye it's 2007-07-26 4:32 How can I do? thanks!SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip filesSuperCool Random Number Generator For different time zones residing on the web server, you can read it from the system registry. Example on how to read it: http://www.codeproject.com/useritems/Custom_Clock.asp Also an excellent site regarding time zone class in .NET: http://www.michaelbrumm.com/simpletimezone.htmlJack Yang.NET Developer...

Contents of the gridview displays for the first time and not other times
Hi, I have a search page which consists of one key. On click of a button on this search criteria a database search on this key takes place. This in turn populates a gridview fields. First time when I run this process the gridview displays all records correctly. Now there is a back button which takes one to the search box. Now again if a valid search is done the grid view does not show up in the result set. I see that the stored procedure has executed without error when I step through the code. I am not sure why this is happening. Any help is appreciated. Thanks CODE:Protected Sub btnFindPa...

Date Time field return just time
 Hi, I have a data/time field in access which is queried using a datasource linked to a check box list, the field contains only hh:mm but is returning dd/mm/yyyy hh:mm, does anyone know how to just return hh:mm? Thanks  Hi, It will return complete date and timestamp so if you want the same to be displayed in hh:mm format then while qerying you will need to format the feild if you want it in hh:mm.  ThanksAshishhttp://itsmeashish.blogspot.com...

Date and time
Hi I have an app that displays events, with an Events table in sql database, containing a column called EventDate (SQL Date/Time) I am trying to output the results from my query as follows January:Event 1 - Event details blah blah - 01/01/2007Event 2 - Event details blah blah - 02/01/2007 February:Event 3 - Event details blah blah - 01/02/2007Event 4 - Event details blah blah - 02/02/2007 And so on, and if no events are listed for that month the month doesn't display I have a simple stored procedure that simply pulls all events with a date of later than today a...

Time only is displayed in date column
Using Thunderbird v1.5, the date column displays only the time on any of the emails that I have composed or received. All imported emails display both the date & time in the date column. What can I do to display the date in the date column? DON RIVAS wrote: > Using Thunderbird v1.5, the date column displays only the time on any of the > emails that I have composed or received. All imported emails display both > the date & time in the date column. What can I do to display the date in > the date column? > > By default, thats how it works mails s...

Display only date part in the GridView control
Hi I have gridview with a column which is DateTime data type. But I only want to display date part on the grid. My data source from SQL server and tried dateVar.ToString("dd/MM/yyyy");dateVar.ToShortDateTimeString(); Nothing is working, in both cased date display with 00:00:00. For example 12/12/2008 00:00:00Any suggesstion?  Have you tried with dateVar.ToShortDateString()Or Use dateVar.ToString("d") Hope that helps  Techie (.Net Knowledge at its Best)We make a living by what we get, but we make a life by what we give.::: Winston Churchill ::: ...

java date time and utc date time
hi i have a client written in delphi the backend is written in java (webservice) when fetching a date field from the db, through java to delphi (TXSDateTime class), for some reason the date changes. in the db: 30/07/2009 00:00:00 in delphi: xsdatetime.asdatetime = 29/07/2009 23:00:00 (1 hour before) in delphi xsdatetime.asutcdatetime = 29/07/2009 21:00:00 (3 hours before) i guess it's a matter of timezones but all we want is simply to fetch the same date as it appears in the DB what are we missing? thanks amos szust wrote: > hi > > i have a client written in d...

Web resources about - GridView - Editing a column only displaying the Time part of a date time field - asp.net.presentation-controls

List of mammals displaying homosexual behavior - Wikipedia, the free encyclopedia
For these mammals, there is documented evidence of homosexual behavior of one or more of the following kinds: sexual behavior , courtship , affection ...

Facebook Displaying Page Insights On Page Admins’ Personal Pages?
Some Facebook page administrators are seeing modules on their personal pages displaying page insights ad, campaign , and like totals for pages ...

Facebook Displaying Unread Messages from Pages in a New Updates Module
Facebook is displaying a new “Updates” sidebar module which shows some users unread messages sent to them by Pages. Users will see the Updates ...

Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air CNN Live - YouTube
Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air Lemon held up a Confederate flag first before holding up the sign. He asked, ...

Hazelwood coal mine fire: Morwell residents displaying symptoms similar to cigarette smokers, expert ...
An expert says some locals near Victoria's Hazelwood mine fire have symptoms similar to cigarette smokers.

Police accused of displaying fake G20 weapons
Toronto's top police officer misled the public by displaying fake weapons used in a medieval-themed role-playing game to help justify their actions ...

No charges for U.S. host for displaying high-capacity magazine on TV
NBC television journalist David Gregory won't face charges for displaying a high-capacity ammunition magazine on his "Meet the Press" news program ...

Jays' Escobar suspended three games for displaying slur
Toronto Blue Jays shortstop Yunel Escobar has been suspended three games for displaying a homophobic slur on his eye-black during a game on Saturday. ...

Google Play Store now displaying age-based ratings
We reported back in May that Google was adding age-based ratings to all apps in the Play Store as determined by the International Age Rating ...

Apple displaying Ferraris & other cars at WWDC hinting at CarPlay announcements
... 2014 Filed under: AAPL Company , iOS Continue reading more about AAPL Company and iOS at 9to5Mac . What do you think? Discuss "Apple displaying ...

Resources last updated: 11/25/2015 9:21:17 AM