473,668 Members | 2,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem Formatting Year

34 New Member
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.ToDateT ime(DropDownLis t1.Text); // this line gives error


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

"OrderDate = CONVERT(DATETIM E, '" + 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 1217
joerozario
60 New Member
use

DropDownList1.S electedValue

or

DropDownList1.T ext.toString()
Mar 22 '07 #2
koonda
34 New Member
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 Recognized Expert Specialist
My favourite method is:
Expand|Select|Wrap|Line Numbers
  1. DateTime.Parse(valuePassed,format,DateTimeStyles.None);
Mar 23 '07 #4
koonda
34 New Member
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
3339
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 into a class as a mocked-up version of the same formatting as _GET and _POST arrays inasmuch as the keys are variable names and vals are the variable values. Here is the print_r printout of $this->propertyArray for example: Array (
2
1421
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 table). When I'm displaying this in a text box in my form I'd like it to display as: dd/mm/yy (including the slashes). Can someone please tell me how to go about this ?
6
3976
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 example In excel in mySQL 45,45 -> 45 2005-01-01 -> 0000-00-00
9
2397
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 that I am comparing Saturdays with Saturdays, Sundays with Sundays, etc ie, 16-feb-06 goes to 17-feb-05 28-july-06 goes to 27-july-05 and so on
7
3106
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
8325
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 date column always shows the date and time while I just want the short date. I have tried applying a format string {0:d} but to no avail. I saw a lot of posts regarding the htmlencode property but I do not know how to turn that off for a...
5
17410
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 windows xp control panel by C# coding or is that any way to set the application date format to d/M/yyyy without change the windows xp regional setting ? Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", false );
2
3148
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 then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
0
3323
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 would like to get the code for connecting the javascript to asp.net page... Please help me... The javascript code is as follows..
7
2094
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 report) from VB form based on an entered date in the masked fields (dd/mm/yy). I am using one form to display five reports. I send date to display report after formatting it (m/dd/yy). When I enter date range like this in masked textbox (DD/MM/YY) ...
0
8462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8799
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7401
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4205
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.