473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problem Formatting Year

34
Hi all,

I am working on a project. Everything is working fine except the date formating. I have five listboxes and a dropdownlist box controls. The 5 listboxes I have populated from the underlying database view and dropdownlist box is populated by the date in the same view. When I select any values from the listboxes the information is displayed in the Repeater Control. I also want to select the date including the 5 listboxes to display the result in the Repeater but when I select the date which is 2006 from the Dropdownlist it give me this error message:

" String was not recognized as a valid DateTime"

I am adding listboxes and dropdownlist into the arraylist which works fine but the dropdownlist with the date won't work. I cannot figue out why is that. Here is the code I am using for Dropdownlist for the date I mean for the year 2006:


if ((DropDownList1.SelectedValue != null) && (DropDownList1.SelectedValue != ""))
{

DateTime d = Convert.ToDateTime(DropDownList1.Text); // this line gives error


string t = d.ToString("dd-mm-yyyy");
Alist.Add(

"OrderDate = CONVERT(DATETIME, '" + t + "', 102)");
}

So it gives me this error : " String was not recognized as a valid DateTime". The whole code works fine for the NorthWind the free database I tried as an example but not for this project

Looking forward to your reply



Koonda
Mar 22 '07 #1
4 1202
use

DropDownList1.SelectedValue

or

DropDownList1.Text.toString()
Mar 22 '07 #2
koonda
34
I used both but it didn't work. Is there any way or any code examples you can send me?

Thanks for your help. looking forward to your reply.

Koonda
Mar 22 '07 #3
kenobewan
4,871 Expert 4TB
My favourite method is:
Expand|Select|Wrap|Line Numbers
  1. DateTime.Parse(valuePassed,format,DateTimeStyles.None);
Mar 23 '07 #4
koonda
34
Hi, kenobewan

Can you explain your code a little bit. I tried your code but still it didn't work.
Looking forward to your reply
Thanks

Koonda
Mar 23 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Phil Powell | last post by:
Hi, I am basing this upon my study of the array_search and array_keys functions in www.php.net and www.zend.com and www.nyphp.org. I have this array, $this->propertyArray, which I have passed...
2
by: Prakash Wadhwani | last post by:
I'm importing & displaying data from a legacy DbaseIII+ system. There's a Numeric field (6 characters) which displays the date in the following manner: yymmdd (stored as a number in the...
6
by: Piotr | last post by:
Hi, I have following problem: I use a form in excel to send data into mysql server, everything is ok unless I have to deal with decimals or data fields, this simple are not recognized. For...
9
by: rjfjohnson | last post by:
Hey, Today is Thursday 16-Feb-06. The same thursday last year is 17-Feb-05. Because I am comparing daily sales between years, I need to know the date of the same weekdayname as last year, so...
7
by: L. Scott M. | last post by:
Have a quick simple question: dim x as string x = "1234567890" ------------------------------------------------------- VB 6 dim y as string
4
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the...
5
by: Tsair | last post by:
I set the thread culture in MAIN() as below in order to show the date in format DAY/MONTH/YEAR, but the datagridview alway show the date in M/d/yyyy. How to set the default Date format from...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
0
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I...
7
by: creative1 | last post by:
Hello everyone. I am experiencing a strange problem that I can't fix on my own. I think I need expert's suggestions for this. The problem is: I want to print account statement (or any other...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.