I am working with WPF and C#. I want to fire an event when the user modifies or selects a date on my raddatepicker control. What event handler should I be using for this? I want to be able to convert this captured date to a SQL server 'datetime' variable for use in the backend.
SelectionChanged is fired when a date is selected or typed + validated.
Related
hi i have a datepicker in my winforms and i want to disable the date exists in my dataBase?
num_reglement = date_paiement.Text + "-" + txtMatricule.Text;
paiement save_paiement = new paiement(num_reglement, double.Parse(txtmontantht.Text),
cmb_paiement.Text, txtbanque.Text, txt_cheque.Text,
date_paiement.Value.Date.ToShortDateString(), txtMatricule.Text, txtlibelle.Text);
save_paiement.insert();
I don't think date time Picker has any such property. It has Max-Date, Min-Date property if you have valid date range, if you want to validate from database ,Only way is to check in Text changed event if value exits in database and show popup of rejection.Otherwise use some third party Control.
I am stucked about datagridview control in which i need to type datetime format in a cell like my own format i need.
I want from the client to enter datetime like "mm/dd" and hit enter, then this field will be seen as a short datetime format.
For example: Client will write "06/27" and hit enter. In cell, it will show 06/27/2015. (The year that we are in). Why i need is that, i will be able to send data in a format that in SQL server accepts.
Should i need also to use it with datetimepicker control or without it i can also handle it?
Well, if you really need to change the value of cell you can use dataGridView_CellEndEdit event and then access cell with:
var cell = dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex];
So here is the scenario:
Page1.aspx:
I created a read-only textbox, followed by a simple calendar.
On selecting the date, the long date appears in the textbox.
Page1.aspx.cs:
created a session and stored the date in it.
Page2.aspx:
Created a label field to house the date value.
Page2.aspx.cs:
now i want to rerieve the date value into the label.
Problem1: on selecting the date from the calendar, the page refreshes and then the data is reflected into the textbox
Problem2: can't convert and store the date values into the label.
Please help.
DataType variable=(Datatype)Session["SessionVariable"];
Retrieve like this by typecasting the session value to its appropriate type.
For Example:
Date variable=(Date)Session["date"];
I'm not sure I understand Problem1 correctly, but it seems that you would like the page to display the date in the textbox without reloading. In that case, take a look at jQuery UI's Datepicker: http://jqueryui.com/datepicker/
As to Problem2, you probably can fix that by creating a new DateTime object with the Parse method. The other way around (from DateTime to string) can be done with the ToString method.
My goal here is to store a list of dates selected in a calandar to a database. The problem with most calendar controls that exist, for asp.net, is I can't get the date that was unselected with multiselect enabled. I can get a list but that is really it. I have decided not to use these because of this.
If I wanted to create my own event using the jQuery calendar below how would I go about doing this? The event would capture the day clicked, if it was unselected or selected, etc. I would use this to add/remove the dates from a collection. It is almost like how the other calendars work except for the remove part. The dates removed would be in it's own list so I know what dates to remove from the database once 'save' is clicked. I hope this is enough information.
http://www.eyecon.ro/datepicker/#about
Using Visual Studio 2005/.NET 2.0. c#
if you wanted to save multiple dates (list), you could:
-use jquery to create 1 input box for selecting date and another list area the selected dates
-on post back, have the server code check the list area for all the selected dates
if you wanted to save only one date, you could:
-use jquery to create 1 input box for selecting date
-on post back, the server code check for the that input box
hope that helps.
Here is the UI of my application. It contains a DataSet, a Save Button, a calendar (monthCalendar), and a DataGridView (columns are Assignment, Description, Date Due, Subject Finished). I want it to do the events:
The Calendar changes the dates to a different color if they are in the date due column
The save button should save the DataSet as an XML file in #"\\Assignments.xml" (that is the application folder right? And not C:\Assignments.xml?)
The row should turn a color if the assignment is finished
I'm sorry it is so much. But my application is complex and I just need these events to finish it. Whoever answers the best will be put in the README.txt file for helping me with the code.
Can't you use a bindingsource, and bind the textbox and the description column to the same field?
For changing Calendar (datetimepicker I suppose?) date, you can add a handler for the Validated event, do a check and update the color in the handler.
To serialize the dataset to XML, you may create a class with all the fields in the data set and parse the data into the object then serialize.
Last one, not sure if you want to do this on load or dynamically or what, but I think you can add a handler for the RowValidated event, and do a check on the finished field and then set the color.