Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2006, 06:01 PM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default Splitting Dates into DropdownList Controls

Hi all

I have seen this before somewhere... what would be the best way to take a shortdate from SQL server database and seperate the DAY, MONTH and YEAR into individual dropdownlist controls?

Kind Regards

Rit
__________________
Rit
www.designandonline.co.uk
INSPIRE | CREATE | DELIVER
 
Old February 3rd, 2006, 12:15 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Why would you want to do that?

You would have to split the colums as you want in the sql, and then use that as your datasource.

 
Old February 3rd, 2006, 12:23 PM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

Thanks,

The reason why I want to do this is that I have inherrited a system and the dates are stored with SQL server as a shortdates. I think it would be better for the user of the site to enter dates in this broken down format to keep control of the varying date formats that could be entered.

Unless there is a better solution that I could look at.

Many thanks Rit01
 
Old February 3rd, 2006, 02:44 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

What does the data look like that you are splitting up. Give some examples

 
Old February 4th, 2006, 04:58 PM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

In SQL Server they use a datetime field e.g. dd/mm/yyyy - 14/07/1949.

So I would need to find a way of seperating them in SQL so that they can be databound seperately and then also handle the data for when the table is updated.

Rit
 
Old February 5th, 2006, 12:51 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I would separate the portions of the date using sql. You can check book on line for string functions such as substring(), mid() .. etc.

Question: Are you populating the drop down lists for data entry? If so, why are you pulling data from the database? Are you giving the users only certain dates they can enter? If there is no restriction, then manually fill the ddl's collection with the values. I guess I am just confused on what exactly you want to do. Also, if you want to let them enter any date, I would use the calendar control. You can restrict the dates they can enter with that control also, so that they can enter a date too far in the past or future.

 
Old February 9th, 2006, 10:49 AM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

Hi
The data coming from the databse is if they have provided a date previously i.e. selected values for the dates dropdown lists.

I might just try the calendar control.

Many thanks for your help anyway.

Rit
 
Old February 9th, 2006, 11:29 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

No problem






Similar Threads
Thread Thread Starter Forum Replies Last Post
FormView - access DropDownList controls kgaughan ASP.NET 2.0 Basics 0 July 29th, 2008 01:40 PM
DropDownList User controls asp.net 2.0 ButtonsBob ASP.NET 1.0 and 1.1 Basics 1 January 9th, 2006 06:18 AM
Splitting a form cwambua Classic ASP Databases 1 August 21st, 2005 11:31 PM
string splitting qwjunk Classic ASP Basics 5 February 2nd, 2004 05:59 AM
splitting this string menesesg Classic ASP Basics 1 September 10th, 2003 12:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.