.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

DateTime int the wrong format causing GridView to not reconize it

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

I am having a problem with the correct dateTime.

Currently I have an application that pumps data into my Microsoft SQL 2005 database. But the dateTime that gets inserted is in the format of, 12 Oct 2010 21:30:24 GMT.

How can i change this on the Sql Database on the backend to the correct format?

View Complete Post

More Related Resource Links

How To Set a Date Format In GridView Using ASP.NET 2.0

A very common desire is to set a column of a gridview to display just the month, day and year of a DateTime type. The problem is the by default, the HtmlEncode property of the boundfield attribute (
The problem is that if this field is enabled, you can not pass format information to the boundfield control. That is, if you try the following code, you will not get the desired result.

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.

How to format datetime & date with century?

Execute the following Microsoft SQL Server T-SQL datetime, date and time formatting scripts in Management Studio Query Editor to demonstrate the usage of the multitude of temporal data formats available and the application of date / datetime functions.


Format Generic List Bound to Gridview


I have a generic list of a custom type. The custom type has a string and double.

I'm binding the list to a gridview and it outputs everything fine.

I'm trying to format the double column into a currency format. It is in a template field as I'm calculating a running total. I pass the value to a function that returns a double and adds the current value to a running total which I will show in the footer.

The format is not changing to currency as expected when using String.Format("{0:c}", GetTotal(Convert.ToDouble(Eval("Amount"))))

Any ideas on what might be going on and how to fix this?


How to format an ItemTemplate value on a gridview control


I have the following in a GridView control:

<asp:TemplateField HeaderText="Count">
         <asp:Label id="lblicount" runat="server" Text='<%# Eval("icount") %>'>

Sometimes the value of this is 0.  I want to display nothing or a blank if the value is 0.  How do I do this?



Datetime format in textbox

Hi I'm retrieving a datetime type of data from sql table databaseMy problem is when I'm retriving it to my textbox it appear something like this -->> 1/10/1990 12:00what i want is to remove the time and appear like this only ---> 1/10/1999 How can I do this?btw I'm using c# Thanks in advance!

DateTime format from sql DataSet

Hello,This is probably a very common question.  But I have a Text Box that is being populated from the database when the page is loaded.  But is displays the time as 8/30/2010 12:00:00 AM.  I need this 8/30/2010.  In the database is it storing the date and time.  I have this which is where the text box is being populated.txt_EventDate.Text = ds.Tables[0].Rows[0]["EventDate"].ToString();How am I able to get rid of the 12:00:00 AM???Thank youvery much!!

DateTime format

Hi, Can anybody tell me how to load todays date in a textbox in dd/MM/yyyy format i used this  txtFromDate.Text = DateTime.Now.ToString("dd/MM/yyyy") I am getting the output as 01-09-2010, but i want my output as 01/09/2010Hi,Can anybody tell me how to load todays date in a textbox in dd/MM/yyyy formati used this txtFromDate.Text = DateTime.Now.ToString("dd/MM/yyyy")I am getting the output as 01-09-2010, but i want my output as 01/09/2010

Format datetime in <%#DataBinder.Eval(Container.DataItem, "DBDate")%>

I have a date in a database which i bring into a repeater using <%#DataBinder.Eval(Container.DataItem, "DBDate")%>.  Can I format the datetime which is write to remove the time bit from it.  At the moment it is written in this format:25/02/2007 00:00:00. I want it to be 25/02/2007 or even a more readable date such as February 25th 2007. Thanks Andrew

My problem with an gridView, Input string was not in a correct format.

Hello all ! I'am actually encounter problem with an gridView which is composed of five columns, the both first are string type, third is date and the two last are linkbutton to edit or delete rows. On clicking edit button, i catch good event to edit and traitment  work fine but on living function an error occur with this message : error : System.FormatException: Input string was not in a correct format. stackTrace :   [FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7471479 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119 System.Web.UI.WebControls.GridView.GetRowIndex(GridViewRow row, String commandArgument) +99 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +602 System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +207 System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175 System.Web.UI.Page.ProcessRequestMain(Boolean inclu

datetime format datatabase

how can i select datetime field as this format dd/MM/yyyy HH:mm:ss

sql datetime format

how can i convert date format from sql to dd/MM/yyyy HH:mm:ss

Format Datetime Parameter Label

I'm trying to format the label of a parameter which is populated by a dropdown in SQL2008 RS. Essentially, i want to put a title in the report which puts the date in the format dd MMM yyyy. I have tried the following options with no luck: =Format(Parameters!MyDate.Label, "dd MMM yyyy") =Format(CDate(Parameters!MyDate.Label), "dd MMM yyyy") Can this be achieved in this way? I "could" reformat the data in the dataset, but i'd rather explore this avenue first. TIAevery day is a school day

Format DateTime in TemplateField

Hi, I am looking to format a date to format dd/mm/yyyy for a template field but I can't seem to get the syntax right. I think it is because my template field links to the method of an object. The template field is:<asp:TemplateField HeaderText="Date Of Accident">                    <ItemTemplate>                        <%#((AccidentObject)(Container.DataItem)).getAccidDate() %>                    </ItemTemplate>                </asp:TemplateField>And all the the stuff on the internet says to format it bythis format<%# Bind("DOB","{0:D}") %>This doesn't work for me I would say because I am using a method. Any help would be really appreciated. Seamus

ASP.NET-Gridview - Export to excel- column format

Hi All, I am exporting gridview data into excel sheet. I have a column  which is a code for which data is like 012,013 etc. But when this data is being exported , in the excel sheet I can see the data as 12,13,14. but actually it should be 012.... Is there any way to specify the format of such columns in my datatable so that they are in the same manner as in the database? Please provide some information on this.Thanks in advance.

i get date in wrong format - need help


i get date from xml in this format:  `7/16/2010 (mm/dd/yyyy)`

i have in my program  `datetime val -  MyDate`.

and when i try to placing   `MyDate = Convert.ToDateTime(7/16/2010)` 

i got error.

how i can fix it ?

thank's in advance

how to retrieve various date format from datetime datatype column


first table

Area_code (varchar)    Loan_date (datetime)

USA                             9/21/2009  12:00:00 AM

CAN                            10/22/2010  12:00:00 AM

ARG                            12/23/2009 12:00:00 AM

Second table

Area_code (varchar)    Date_format(varchar)

USA                             dd/mm/yy

CAN                             yy.d.m

ARG                            yy'?'d'?'m'?'

I want to add Loan_date column in second t

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