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

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

Insert the date as a hidden field using details view

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :ASP.Net

When adding a new record. I have a field that displays the current date using now(). I want to make that a hidden field and simply insert it into the database when the new record is submitted.

I tried making it a template field and then deleting the textbox and inserting a hidden field but I can only either bind it to the field in the database or use custom binding to add the date value 'now()'... I don't seam to be able to do both.

any ideas ?

View Complete Post

More Related Resource Links

Calculated date field displays differently in List View and Data View web parts

In SharePoint GUI I created a simple custom list with a calculated Date/Time field (Due).  The calculation is =[Created]+7.  I'm trying to display this data on a page using a DVWP.  But first, for testing purposes, I also created a second calculated Date/Time (TestCreate) field in my custom list that is simply =[Created]. In the List View from within SharePoint, the dates show as expected (for example): Created = 8/12/2010 3:45 PM Due = 8/19/2010 3:45 PM TestCreate = 8/12/2010 3:45 PM In SharePoint Designer, I added a Data View web part and the above three data elements (each configured to display mm/dd/yyyy hh:mm:ss tt).  I see the time displayed for the example list item as: Created = 8/12/2010 3:45:30 PM Due = 8/19/2010 10:45:00 AM TestCreate = 8/12/2010 10:45:00 AM I've tested a couple scenarios and the calculated fields always display five hours in the past (along with dropping the seconds).  It seems like the DVWP is returning the date in a different time zone (with no seconds).  The lcid is set right (1033).  I didn't see any time zone settings for the DVWP specifically.  I'm basically stuck.  Could someone help me figure this one out. Thanks.

What is the difference between view state and a hidden field


What is the difference between view state and a hidden field?

As we know that view state allows the the state of objects to be stored in hidden fields and is stored in client side. but what is the exact difffrence between a view state and a hidden field

Collect Feedback workflow hidden field


Hello all,

I am using the out of box Collect Feedback workflow.  It works well for most part.  However I would like to get reviewer's feedback to be shown on a Dashboard.  Is there a way to expose that information in a Data View?  I couldn't figure out which data field stores the feedback information.


Insert DATE to database (format 'YYYY-MM-DD')

How can I insert BIRTHDATE into column in 'YYYY-MM-DD' format. This is my code, can anyone edit my code? Tnx String = "INSERT into concfile VALUES(BIRTHDATE('" & DateTimePicker1.Text & "', 'YYYY-MM-DD'))"

Details view

I am currently using a Grid view to list out some information about the products in my database. When selecting on Select button, a Details view with more information is shown at the bottom, Question is - how do I show the Details view in a new page instead of being at the bottom of the same page? Thanks for your help. 

how can I make field with date in format: dd/mm/yyyy ?

I have in model:[DisplayName("Publication date")] [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)] [Required(ErrorMessage = "Publication date is required.")] public DateTime publication_date { get; set; } And in view:<div> <%: Html.LabelFor(model => model.publication_date) %> </div> <div> <%: Html.TextBoxFor(model => model.publication_date, new { @class = "datepicker" })%> <%: Html.ValidationMessageFor(model => model.publication_date) %> </div> But when I write in this field date: 30/11/2009 I see validation error: The value '30/11/2009' is not valid for publication_date.

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.. 

Updating a List item field value in a SPD Workflow is setting Date fields to null

Hello everybody,I faced a very weird behavior while creating a workflow in SPD against a Document Library.Here is the case:1- Create a document library in sharepoint site.2- Add a custom column of type DATE.3- Upload any document to the library4- Edit the item metadata and set the custom date field to any date you want.5- Now using sharepoint designer, create a very simple Workflow with only one action that updates the current item "Title" field to any value. (Note: In my case I set the workflow to start manually and not automatically)6- Save the workflow and then start it on the uploaded item.7- Now check the value of the date column after the workflow is finished.8- You will see that the Date field is Empty... (very weird)Notes:   1-This behavior will not appear on a standard list. it is only appearing in a Document library.  2- I am using WSS 3.0 SP2 + MOSS 2007 SP2. Also SharePoint designer 2007 SP2Did anyone face this situation and does it have a fix, or am I doing something wrong here... Please help.Regards,Maheed

Displaying Calendar Description Field In Calendar View

In the default "out of the box" calendar view it only shows the Title of a calendar event. Is there any way to show not only the Title field but also the Description field?

How to get "Current Date" on SharePoint Designer for Invoice Ageing Data View Report??

Hi Experts, I would like to know how can i get/show "Current Date" in SharePoint Designer ?? Any good tutorial ? FYI, I need this "Current Date" for my Ageing Data View Report, Purpose To offset with "Invoice Receive Date" to get total days of payment payable for the invoice. Please assists, Thanks

New / Upload / Actions / Settings / View menus on a document library are hidden

I have a Document library. On the View Page (All Documents) for the Document library, I do not see the menu bar with the "New / Upload / Actions / Settings / View" menus. It looks like one of the users with owner permissions did something to cause this behavior. No custom code exists on the page. I am not sure how this menu bar can be hidden. Can someone please clarify. I am a site collection administrator.

How do I format a date time field in a CQWP to YY-MM-DD ?

Hi. I have been trying to get the date-time to look good for some time now, but have failed. I have a Content Query web part that picks up article pages from a page library. The pages contains a field called 'article date'. I want to show just the 'Title' and the 'Article date'. Doing this default gives me: My title 10-09-03 00:00:00 I want it to be: My title 10-09-03 Is this possible? I'm starting to realize that I probably have to edit the xsl styles for this webpart but if thats the answer, how do I do that? ThanksThomas Balkeståhl - Technical Specialist - SharePoint

Why can I not group by calculated field in Date format?

After migrating to SP2010 Foundation, I've discovered that for some reason I can't group a list by a calculated date field. Ex: Create a list with a date column A. Create another column B with a simple calculated date of [A]+1 and use the field format type 'date' Modify view to group the list by column B.  You're list will load, but when you attempt to expand one of the groups you'll be greated with an exception error. Why?? Am I doing something wrong? Note: You can group fine if the data type for column B is anything except 'date' format, but I really need to group items by a calulated date. Ultimately, what I'm trying to do is group my list items by week by calculating the end of the week using a simple formula =[Must ship by]+7-WEEKDAY([Must ship by])  then I want to gropu by the [Must Ship by] column like I always did in SP 2007, but now it errors out.  I also wanted to create my own timesheet template since the Fab 40 templates aren't available for 2010, but I can't really do that effectively without being able to group timesheet entries by week.  

Trying to generate a view with Details.tt

I'm using Entity Framework and I have Mvc 1.0 installed.I keep getting weird errors when I try to generate a view for my details method. The first time I try to gen I get: error CS0234: Compiling transformation: The type or namespace name 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?) I rebuild and then I get: CodeTemplates\AddView\Details.tt(-1,-1) : error : The host threw an exception while trying to resolve the assembly reference 'System.Data.Entity'. The transformation will not be run. The following Exception was thrown:System.ArgumentOutOfRangeException: Length cannot be less than zero.Parameter name: length   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)  Anyone have any ideas? I've searched google...I've searched the forums...I've moved the .tt templates into my solution. No luck.

how to force null in date field - access 2007 ?

hi i have table that contain date field. how i can force null or empty value on this field ? thank's in advance

Hidden field not available in XSL

Hi folks, I have a Custom List that uses a ContentType which defines a column as Hidden (will not appear in forms). When I create a DVWP, this column is not available - i.e. <xsl:value-of select"@MyColumn"/> gives a blank value. Changing the column to "Optional" fixes this problem, but then the field appears in the normal edit / display forms. The column's value is set programatically by a web-part. Is there a setting I have missed to allow a field to be viewed using a DVWP but not in the standard edit / display forms? or any other reason why the value would not be showing up in the DVWP when the column is set to Hidden?? Thanks, Alex

Custom field type - set value doesn't work when field is hidden

Hi, I have a simple custom field type which gets a value from the Property Bag and sets that value to a label. This works fine as long as the field is set to Optional (the field is a site column and is part of a site content type), but if I set it to Hidden, the value doesn't get set. public override void UpdateFieldValueInItem()         {             this.EnsureChildControls();               if (this.ControlMode == SPControlMode.New)             {                 this.Value = GetChosenConsole();             }         }   Does anyone know why this is and what I need to do in order for it to work even though it's hidden? Thanks!
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