How to pass value from datepicker when editing a existing entry in a gridview. For instance I have a column name ExpirationMonth with a cell data of AUG, and I want that to pass in a DatePicker Input, instead of seeing the watermark "Enter date". See the first Image.
The first image when editing a certain entry in a gridview, Aug does not show up in the ExpirationMonth, 2014 does not show up in Expiration Year.
Also when I add an entry still the same even it has a default value, set as
But when I select a month for ExpirationMonth, month I selected appears in the DatePicker input. See the second Image.
What I did to show month and year in the Datepicker Input, here is the code snippet:
Regards,
Robert Peter Mansion
The first image when editing a certain entry in a gridview, Aug does not show up in the ExpirationMonth, 2014 does not show up in Expiration Year.
Also when I add an entry still the same even it has a default value, set as
//for ExpirationMonth
DateTime.Now.ToString(
"MMM"
);
//for Expiration Year
DateTime.Now.ToString(
"yyyy"
);
But when I select a month for ExpirationMonth, month I selected appears in the DatePicker input. See the second Image.
What I did to show month and year in the Datepicker Input, here is the code snippet:
public
CreditCardWindow()
{
InitializeComponent();
CultureInfo cultureInfo =
new
CultureInfo(
"en-US"
);
DateTimeFormatInfo dateTimeFormatInfo =
new
DateTimeFormatInfo();
dateTimeFormatInfo.ShortDatePattern =
"MMMM"
;
cultureInfo.DateTimeFormat = dateTimeFormatInfo;
dteExpirationMonth.Culture = cultureInfo;
string
dteMonth = dteExpirationMonth.SelectedValue.ToString();
dteMonth.ToUpper();
CultureInfo cultureInfo2 =
new
CultureInfo(
"en-US"
);
DateTimeFormatInfo dateTimeFormatInfo2 =
new
DateTimeFormatInfo();
dateTimeFormatInfo2.ShortDatePattern =
"yyyy"
;
cultureInfo2.DateTimeFormat = dateTimeFormatInfo2;
dteExpirationYear.Culture = cultureInfo2;
}
Regards,
Robert Peter Mansion