Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3276062
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:12:55+00:00 2026-05-17T19:12:55+00:00

I have a Gridview where I can modify the Time portion of a DateTime

  • 0

I have a Gridview where I can modify the Time portion of a DateTime field. The update method is working well, except for one thing:

The field should only allow the time portion, e.g 08:23:09 but on the Database it saves it as a full DateTime, e.g 10/18/2010 08:23:09 AM. The problem is that upon editing, instead of adding the existing Date portion, it adds the current Date portion. So if I am editing the item from the last example into 08:25:09 instead of adding it as 10/18/2010 08:25:09 AM it adds it as 10/20/2010 08:25:09 AM which is obviously undesired behavior.

Here’s how I am doing the update:

protected void grvOutHour_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
       GridView grvOutHour = (GridView)this.grvReport.Rows[grvReport.EditIndex].FindControl("grvOutHour");
       TextBox txtBox = (TextBox) grvOutHour.Rows[e.RowIndex].FindControl("txtEditOutHour");
       string outHour = this.Source[grvReport.EditIndex].EntryDate + " " + txtBox.Text;
       odsOutHours.UpdateParameters["OutHour"].DefaultValue = outHour;
    }

Up to this point, outHour ‘s value is the desired one, e.g 10/18/2010 08:25:09 AM but as soon as the value is passed to my actual Update method:

public static void UpdateHour(int pEntryID, DateTime InHour, DateTime OutHour)
    {
         Hour hour = HoursDataMng.GetEntity(pEntryID, InHour.Date, InHour.TimeOfDay);
         if (hour == null)
             return;
         else
         {  
             hour.OutHour = OutHour;
             HoursDataMng.SubmitChanges();
         }
     }

I can see that OutHour has changed to 10/20/2010 08:25:09 AM

What’s going on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:12:56+00:00Added an answer on May 17, 2026 at 7:12 pm

    Save the old Datetime in HiddenField then in the Update method get new value of the time and replace it in the old DateTime(From HiddenField) then pass the result to DB Parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview which can be filtered from one or more values in
I have GridView which I can select a row. I then have a button
I have a gridview control that can get loaded with multiple pages worth of
I have a GridView where one column is bound to an object property containing
This is a new one I have never seen before. I have a gridview
I'm trying to modify a field in each row of my gridview as it
I have a gridview where I can select multiple rows by pressing a control
I have a gridview that contains one linkbutton within itemtemplate. I bind this gridview
I have a GridView which needs to get updated on RowUpdating Event. How can
I have a GridView control in an Asp.net application, that has a <asp:buttonField> of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.