Opening up a Calendar when clicking on a Text Box

Please see attached graphic first.

I would like my users to be able to:
1.  Click on the 'Date' text box and then a small calendar to open up where they will have to select the day, month and year.
2. Select the 'Display" text box and change the desired number of lines they wish to view in the gridview below. (it will default to 10)
3. Then click a Submit button and see the results.
4. The Result gridview will show 10 lines or the desired 'display" value of lines entered.

The table to display has 4 fields,   Date (datetime), day(varchar), PeopleHelped (INT), Value(smallmoney)
, and to make it easy on me, I have already created a record for each day of the Year 2008 and 2009, so all they have to do is to click on the 'edit' icon in the Gridview to start editing.  Users will do this process daily.

Question:  How do I make a Calendar appear when they click on the date textbox? and how do I pass this variable to the gridview.  Also, how do I pass the value of the variable 'display' to my gridview?

I hope this is not confusing.  Thanks,
Aaron ThornAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
why don't you use a DateTimePicker control?
0
Aaron ThornAuthor Commented:
Does Visual Studio 2008 have the Date/Time picker control?  I did not see that in my Toolbox.  Also, I have read about using AJAX or ATLAS  ????, which I am trying to avoid unless I have too, I have it on my PC, but I don't know if I need to install AJAX in my ASP.net server?

If the Date/Time Picker control is not part of Visual Studio 2008, where can I find it?

Thanks,

Attached is the graphic I forgot to attach !!!!!


Request1.jpg
0
Éric MoreauSenior .Net ConsultantCommented:
You are doing web application. That's good to know! Have a look at http://www.eworldui.net/CustomControls/CalendarPopup.aspx
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Aaron ThornAuthor Commented:
Thanks Emoreau,  I just downloaded the eworldus from the link you sent me, I have run the install, but I don't see it in my Toolbar  column in VS2008 ... I am searching on their site to see how to make it work ... If you know the fastest way, please let me know. thanks.
0
Aaron ThornAuthor Commented:
Okay, finally I got it installed.  I just need to play with it and see if I can pass the date selected from the calendar to my gridview.  Thanks.
0
M3mph15Commented:
The easiet thing to use is the Calender Extender from the ASP.Net Ajax Control Toolkit.
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/Setup.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Aaron ThornAuthor Commented:
Hello guys,

I having problems making AJAX work.

My system:  Visual Studio 2008 Professional SP1, ASP.NET 3.5 (reinstalled okay, not needed but I did it anyway), Downloaded the latest AJAX ControlToolKit from the ASP.NET website, I installed properly, I see the Toolbox for AJAX Toolkit but I cannot drag it into my form, it does not let me, I have created a test ASP.NET Website , I did not see the template AJAX enabled site, I read that in SP1 and 3.5 it will not show in the list of templates.

If you have another alternative for this Calendar popup please let me know.

Also I have tried the one from www.eworldui.com  as recommended by 'emoreau' but seems to work, but when I cannot bind the calendar text box with my GridView, I don't see the calendar ID so I can pass the selected date to my gridview results.

Thanks.
0
M3mph15Commented:
Hi,
When i installed the AJAX ControlToolkit i didn't get that AJAX enabled website template either. All you need to do is add a script manager onto the page, thats all the template changes i think.
As for dragging it onto the page, the easiest way i find to use it is in design view click on the textbox and then click on the little arrow to the right that should expand a small menu with an option "Add Extender". This will show all the available extenders for that control.
0
Aaron ThornAuthor Commented:
M3mph15,
It must be something obvious that I am missing.  See attached graphic: You see that I have all the Ajax controls in my Toolbox on the Left, they are not grayed out at all, as soon as I drag it out of the Toolbox, it shows me the symbol that it cannot be done ( this is the NO symbol, the circle with the slash across), I even have the Script Manager there, also when I place a Standard Text Box, I don't see the little arrow anywhere that can give me the "Add Extender" option, I tried looking for it.  

What drives me crazy is the fact that when I run the Calendar Demo that came with the AjaxControToolkit.zip it runs perfectly fine, please see the second attached image.

Thanks,
ajaxdemo1.jpg
ajaxdemo2.jpg
0
M3mph15Commented:
Hi,
The controls from the AjaxControlToolkit con not be dragged onto the webpage in desing view. They can however be dragged into the source view. And then in the source view you can set the TargetControlId to set which control it will extend.
Also i Have attached an image of the arrow i was talking about.
Either method will work. Going through the menu that the arrow shows will set the TargetControlId etc. automatically.

HTH
-M3mph15

textbox.bmp
0
Aaron ThornAuthor Commented:
Thanks M3,

I made lots of progress with your info. Thanks!  I just need to know how to pass the selected calendar date to my GridView.  I want the user to select the 'date' from the calendar and then click Submit, and refresh the GridView to start with that selected calendar date.  Please see attached image of my progress.
ajaxcal2.jpg
0
M3mph15Commented:
Ok, When you say start from that date do you mean show records from that date and onwards or just the records with that date.

What is the datasource of your gridview (in other words where is it getting the data from Database etc.)
If it is from a Database. What i would do is On the click of the subimt button create an sql statement with a WHERE clause including the selected date.
e.g "SELECT [columnnames] from [tablename] WHERE DATE = " & txtDate.Text
txtDate is the name of your textbox. Also you may need to use the TO_DATE function depending on what database it is.

That sql statement can be set to the SelectCommand of the Database and then you can rebind the GridView to show the changes.
HTH
-M3mph15
 
0
M3mph15Commented:
Soz. correction That sql statement can be Set to the SelectCommand of the DataSource*
0
Aaron ThornAuthor Commented:
Hello M3,
After trying your advise I get this (see attached images).  My control text box is called txtDate , and when I pass it to the Grid, it gives me a DateTime format error, how can i convert from txtDate.txt to a Date format?   also, please what is the string I may use if I want to set txtDate to Today's date?

I used the string -->   & txtDate.Text    as you provided.  Thanks.

Thanks M3.
datetimeerr1..jpg
datetimeerr2..jpg
0
Aaron ThornAuthor Commented:
Thanks for the follow up!
0
M3mph15Commented:
Ok, So the grid is looking for something in the format as DateTime. Depending on what format your date is in you can adjust the code accordingly. I'm going to assume your date is something like 21/12/2008. (Day/Month/Year) Try the following:

Dim s As String = txtDate.Text
Dim t() As String = s.Split("/")  'This will split the string at each '/'
Dim intDay As Integer = System.Convert.ToInt32(t(0))
Dim intMonth As Integer = System.Convert.ToInt32(t(1))
Dim intYear As Integer = System.Convert.ToInt32(t(2))
Dim dt As New DateTime(intYear, intMonth, intDay)  'Then pass this to the grid.

As for the default value of Date i believe you can use SYSDATE to get todays date. Or if you are doing it in the code behind Date.Today works aswell.

HTH
-M3mph15
0
Aaron ThornAuthor Commented:
Hi M3,
1.  I tried sysdate with no avail, also I tried getdate(),  Date.Today in the value field, and still cannot make it work.  Please see attached image.
2.  All  I need is to click on the Calendar Extender, select the Date I need my GridView to show me and clck submit. Since the txtDate  control box is a text and is passed to the Gridview date colum it tells me the is an improper format DateTime.
3.  There must be a simple way of passing the text value in txtDate (from my calendar selection) to the 'date' field in my GridView below.
4. I did not know where to insert the code you sent me last time, does that go in the codebehind for the GridView? or the submit button? or the txtDate?

Thanks.
grid2err.jpg
0
M3mph15Commented:
Hi,
I am not too familar with the way you are using so unfortunately i'm out of ideas sorry.
0
Aaron ThornAuthor Commented:
Anyone one there that knows Visual Studio 2008.  This problem is the most basic.  The question is, how do you pass a Calendar selected value from an AJAX Calendar extended to a text box, to a 'date' colum value on a Gridview? without writing any code or very little code with specific instructions.  The Client here does not know any coding.

0
Aaron ThornAuthor Commented:
Nobody has reponded in a week.  I am closing it without a solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.