'System.String' to 'System.DateTime' error


I have a Gridview with templates and i set the format to

Text='<%# Eval("PrescriptionDate", "{0:dd/MM/yyyy}") %>'

 The objectDataSource:

<asp:ObjectDataSource DeleteMethod="DeletePrescriptionDetails"

InsertMethod="InsertPrescriptionDetails" ID="objDetails"

runat="server" SelectMethod="GetAllPrescriptionDetails" UpdateMethod="UpdatePrescriptionDetails" TypeName="GridViewClasses">


<asp:Parameter Name="PrescriptionId" Type="Int32" />

<asp:Parameter Name="MedicineId" Type="Int32" />

<asp:Parameter Name="ActualDose" Type="Int32" />

<asp:Parameter Name="RouteId" Type="Int32" />

<asp:Parameter Name="InfusionRate" Type="Int32" />

<asp:Parameter Name="InfusionVolumeId" Type="Int32" />

<asp:Parameter Name="PrescriptionDate" Type="DateTime" />





<asp:Parameter Name="id" Type="Int32" />




<asp:ControlParameter ControlID="hdnPresID" Name="PrescriptionID" PropertyName="Value"

Type="Int32" />




If i enter a value such as: 18/10/2006 then when inserting i get the following error (if i enter something like 02/02/2003  then it's fine)

Cannot convert value of parameter 'PrescriptionDate' from 'System.String' to 'System.DateTime'

What is the problem? Thanks

11/6/2006 10:14:39 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 29

Did you set your app's culture? see globalization section

By default the Date is parsed in us culture, that's MM/dd/yyyy, and there's no 18th month..

你好! Just FYI o_O
11/7/2006 7:46:17 AM

Similar Artilces:

System.Net.Mail is giving error CS0029: Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress'
I'm getting an error while trying to use the wizard to create a form and than pass it the vaibles to Mail. Any help would be much appreciated. SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); try {   message.From = txtEmail.Text; message.To.Add("admin1@yoursite.com"); message.Subject = "Feedback"; message.CC.Add("admin1@yoursite.com"); message.CC.Add("admin2@yoursite.com"); message.IsBodyHtml = false; message.Body = txtMessage.Text; smtpClient.Send(message); lblStatus.Text = "Email successfully sent."; } catch (Exception ex) { lbl...

'System.String' to 'System.Guid'
 Hi Guys, I have this working with a hyperlink field in a gridview.   <asp:HyperLinkField DataNavigateUrlFields="UserID" DataNavigateUrlFormatString="userprofiles.aspx?UserID={0}" DataTextField="UserName" HeaderText="User Name" Text="User Name" >  I just want to same thing in a datagrid but I get this error:  <asp:HyperLink ID="HyperLinkToUserProfile" runat="server" NavigateUrl="userprofiles.aspx?UserID={0}"><%# Eval("UserName...

Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/ GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

Cannot convert value of parameter 'Course_FK' from 'System.String' to 'System.Guid'
Hi, I'm building a site and I've been trying to accomplish something similar to what is talked about in "Working with Data in ASP.NET 2.0 :: Declarative Parameters" tutorial. Below is the code for my methods from the xsd. I tried to attach a screenshot of my xsd but for some reason I'm not allowed GetAllCourseNames() SELECT        CourseID, NameFROM            Course GetCourseScheduleByCourseID SELECT        ScheduleID, Course_FK, Date, TeeTime, NumberOfPlayersF...

Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

Unable to cast object of type 'System.DateTime' to type 'System.String'.
 Hi,      I got this field (dateSubmitted) having a data type of DateTime but I receive this error "Unable to cast object of type 'System.DateTime' to type 'System.String'."       All value for dateSubmitted field are 12/27/2007 12:00:00 AM. cheers,imperialx  imperialx:I got this field (dateSubmitted) having a data type of DateTime but I receive this error "Unable to cast object of type 'System.DateTime' to type 'System.String'." Can you explain it further as to, ...

Error 102 Argument '12': cannot convert from 'ref System.Guid' to 'System.Guid?'
Hi  I have a stored proc as follows: USE [SubSrvs]GO/****** Object:  StoredProcedure [dbo].[subsrvs_Services_CreateService]    Script Date: 07/15/2007 11:39:38 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[subsrvs_Services_CreateService] @Level1    nvarchar(max),    @Level2    nvarchar(max),    @Level3    nvarchar(max),    @Level4    nvarchar(max),    @Level5    nvarchar(max...

Unable to cast object of type 'System.String' to type 'System.Byte[]' error
Hello, I have some binary data in a MySQL database, and im trying to convert it to a file. Before, when i was using the ms sql express 2005 database, everything was working fine. But then i migrated to MySQL because of budget issues. The following is the block of code that produces the error.private void showDbImage() {string ImageId = Request.QueryString["img"];   //build our query statementstring sqlText = "SELECT DownloadFile, DownloadType FROM DownloadTable WHERE DownloadName = '" + ImageId +"'";  OdbcConnection connection = new O...

ERROR: Unable to cast object of type 'System.Boolean' to type 'System.String'
I created a class to update, insert, select and delete data with an object data source but I am getting the following error... body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-wei...

Hi everyone,I'm using the SqlTableProfileProvider  to store my profile info, including a field "DOB" (date of birth) which is a DateTime type.I have no problem storing the DOB datetime field. But when I try to retrieve it using:ProfileCommon p = Profile.GetProfile(User.Identity.Name); DOB.Text = p.DOB;I get an error on the following method in the autogenerated codefile "App_Code.7y-deadj.3.cs":public virtual string DOB {        get {            return ((string)(this.GetPropertyValue("DOB"))); //ERR...

Convert 'System.DBNull' to type 'System.String' ?
I have a textbox on my site that I want to populate with some data, however when the value is null, which is quite often.The problem is that when I call a static method which returns a string; when that string is DBNull, I get the following error which is absolutely correct.Unable to cast object of type 'System.DBNull' to type 'System.String'.So, what should I do to be able to ignore that the string is null and just display a "" string in the texbox?The code is as follows:    private void GetCartSmall(string sSessionID)    {      &n...

Datetime for Inserts
 Hello all Is there a way to do this, or is there a better way?public static DateTime DateTimeForInsert(DateTime myDateTime) { if (myDateTime == DateTime.MinValue || myDateTime == DateTime.MinValue || myDateTime.ToString().Length > 0) { return DBNull.Value; } return myDateTime; }     Cannot implicitly convert type 'System.DBNull' to 'System.DateTime'Remember to click “Mark as Answer” on the post if it helped you. Thank you! You should use nullable types.   public static DateTime? DateTimeForInsert(DateTime? d) {  &nb...

Cannot implicitly convert type 'string' to 'System.DateTime'
Hi, I have a DateTime field in my sql server database. The field can take null value. In my aspx page, i have a textbox to get the input from the user. If the textbox value is empty, how to handle it? This is my cs code: objMyTime.StartTime = DateTime.Parse(txtStartTime.Text);   I am getting error as: "Cannot implicitly convert type 'string' to 'System.DateTime' " Thank you  seems to me objMyTime.StartTime is a string and ur trying to assign the datetime.try with this objMyTime.StartTime = DateTime.Parse(txtStartTime.Text).ToString();use RequiredFi...

'System.Web.UI.Control' cannot be converted to 'String'.
I am trying to run a simple Edit, Update, Delete. I found a simple example in a book I've got. My only concern is withing the string it's first Declaration is Read only, so it won't be edited. and for some reason I am getting this error: The update function that is right after the page_load is giving me the problems. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC30311: Value of type 'Sy...

Web resources about - 'System.String' to 'System.DateTime' error - asp.net.presentation-controls

Resources last updated: 1/8/2016 8:10:06 PM