Two CalendarExtenders? - c#

I have a popup ajax calendarextender that populates a text box with the selected date, (MM/dd/yyyy). This works. I want to capture the same date in an additional text box with a different format (yyyyMMdd). The first is for display and the second date is a parameter for gridview query. Is this done with two calandarextenders? (btw I'm using C#)

If you are supplying one to a query, you could just change the parameter value in code before supplying it to the query.
var datetimeForQuery = extenderVariable.SelectedDate.ToString("yyyyMMdd");

Related

DeafultcCellStyle format not working on unbound DataGridView C# Winforms

I have an unbound DataGridView that I populate with data from an SQL database. One of the columns in the database is of type ‘datetime’.
On the load event of my winforms application, I use code below in order to format the column to only show date part of datetime column. However it shows the full datetime. I want 18/02/2020 and it’s showing 18/02/2020 00:00:00
dgv.Columns["Date"].DefaultCellStyle.Format = "dd/MM/yyyy"
dgv.Columns["Date"].ValueType = typeof(System.DateTime);
How do I format the column to only show the date portion of the datetime column?
I added some data in the gridview within my code and tried your code above. The DefaultCellStyle.Format works well.
Which means that you might need to check the way you're retrieving the data from your SQL Database. You may be filling your grid with strings instead of "dates" for example.

How to modify data before diplaying it in DevExpress Reports

I have several pages that contains a Report in each one, and I used a base class for these pages called ReportBasePage.
The Report shall view some date fields in it beside other fields, and now I want to do some modifications on the report parameters before displaying them on the report. How could I do that?
In other words, I want to change the date format from the base page before being displayed on the report.
If you want to show the date in different format, you can change the FormatString of the control that is displaying the date value (for example XRLabel). Set the FormatString to your desired date format (for example "{0:dd-MM-yy}")
If you need to change the value (not the format) of the report parameters, you can do it using the XtraReport event "ParametersRequestSubmit".
Regards.

How do I Compare values in column of a gridview

I am using asp.net 4 and c#.
I have a gridview with a textbox that needs a unique value for the database. This value is to sort the data by precendence with in the database.
All my other validators work but they only check the value in the one box.
How do I validate that the integers are unique in that column.
The only thing I found to do this is "DataKeyNames" but that does not stop it from allowing repeating numbers.
Updating the order is done on button click.
Thanks for info.
You can use a customvalidator for validating this. In the CustomValidator's OnServerValidate function you can repeat through all the rows of the grid view, get the textbox and its value and perform the unique check.
For the Integer validation you can add a CompareValidator with Operator="DataTypeCheck" Type="Integer"
I suppose you could write a JavaScript method that will scan the contents of the grid onclientclick before submit.

Make dates in datetimepicker grey?

Im writing a hotel booking system with VS2012 which uses ms sql and in the booking i have two datetimepicker controls. When i select a date in the first one the date automatically gets transfered to the second datetimepicker. I now want when the user opens up the second datetimepicker not being able to select a date that is before the first date from the first datetimepicker. I dont want to use if method displaying a message i just want the dates to be "greyed" out.
Is that possible and how?
*edit (screenshot of how i would like it to be viewed or similar http://i43.tinypic.com/2zpimvs.jpg )
*edit2: its not the control(dateTimePicker2) it self i want to grey out, its the dates inside it that is smaller then the date selected in dateTimePicker1. The screenshot provided is in the area of what im looking for.
You could try this:
DateTimePicker2.MinValue = Convert.toDateTime(DateTimePicker1.SelectedDate);
EDIT
Standard controls don't support the grey-out of a datetimepicker. If you want to do this, you need to subclass the datetimepicker or look at a premade control like a DateEdit from devexpress (i think they even have free controls).
Change the second datepicker MinDate to first DatePicker selected date .. like below ..
rdpDatePicker2.MinDate = rdpDatePicker1.SelectedDate.Value;

How to display filtered data in asp.net using linq to sql

I have to display data from a table on a gridview in an asp.net webform application. When the page loads, it should show a 30 day worth of data based upon the createddate field in the table. Above the grid, I have two date picker controls, which can be used to select a date range; when a date range is selected, it should show data based upon the dates. I am restricted to use only linq-to-sql for data access. One option is to select all data from the table, when the page loads, then display 30 day's worth of data. Filter the data if date range is selected, subsequent to page load. However the problem is that it may bring too much data. Please let me know a better option.
Thanks
Filter in the database - which is basically how most of Linq-to-SQL will work anyway. You just need to write the where clause using your date range.

Categories

Resources