asp.net label currency format - asp.net

Hi how do format my label to a currency format.
code
lblFundsAvail.Text = result.Data.FundsAvail.ToString();
thanks

Try using the format specifier C:
lblFundsAvail.Text = result.Data.FundsAvail.ToString("C");
Note though that this will use whatever currency the server happens to have as its current culture, and this may not be the currency you want. You can specify another culture as the second parameter.

Related

I want to display time as 09032014124008 rather than 9/3/2014 12:40:08 AM

I want to display time as 09032014124008 rather than 9/3/2014 12:40:08 AM
When I use DateTime.Now, the format is the latter one.
Kindly suggest how can I get it in the required format.
You can specify a custom format string on the call to .ToString()
For your example you would use:
DateTime.Now.ToString("MMddyyyyhhmmss")
Also see here for additional format string options

How can i Convert the DatePicker Input to string

I am using the following Codes to get the date from the date picker
objDD_ml.EffDate=(DirectCast(drv.Cells(3).FindControl("rdpEffDate"), RadDatePicker).DateInput).ToString
But it does not return the date... It returns like 'DateInput'
How can i use the code to get the value for Effdate as a correct format of date
Anyone please help me..
Whenever you want date into string and in specific format you can always apply following :
objDD_ml.EffDate = (
DirectCast(drv.Cells(3).FindControl("rdpEffDate"), RadDatePicker).DateInput
).ToString("dd/MM/yyyy")
Try to cast the FindControl object into the corresponding ASP control externally. Then access the value of that control and convert it to .ToString
I don't know what control you are using, but it should be something like below -
objDD_ml.EffDate = ((RadDatePicker)(drv.Cells[i].FindControl("rdpEffDate")).SelectedDate.Tostring;

DateTime string format (dd.MM) localized XAML

I found some usefull question but they didn't helped me. I'm developing Windows Phone 8 app and I want to show only dd.MM on TextBlock (DateTime binded) if culture is Turkish. If culture is en than display MM.dd
Text="{Binding MyProperty.CreateDate, StringFormat=\{0:dd.MM\}}"
Above code runs true in Turkish culture. But in English it's meaningless. Actually problem is not with the English or turkish. I just want to show Day and Month formatted in current culture.
If you want to specify your own format, you can create different format strings in your localization resource files and bind to StringFormat
Text="{Binding MyProperty.CreateDate, StringFormat={StaticResource shorDateFormatString}}"
Alternatively, set the date text in the codebehind, with some custom logic to see whether the month or the day comes first in the local convention
string shortDatePattern = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern
if(shortDatePattern.indexOf("dd") < shortDatePattern.indexOf("MM"))
dateLabel.Text = MyProperty.CreateDate.toString("dd.MM")
else
dateLabel.Text = MyProperty.CreateDate.toString("dd.MM")
As suggested in this response

Parse string pattern into Date in Flex

Is there some way in flex to parse strings to date. I want it to support custom formats similar to 'dateformatter'. Using 'dateformatter' class we can parse date object in various string formats as specified by 'formatString property'. I want it other way round, from string to date. The parse method 'Date.parse(my_string)' does string parsing but for a very limited set of formats. Can't we have something similar to following, where user can specify his/her own formats.
someformatter.formatString = 'HH::MM::SS' ;
mydate = someformatter.formatTodate('23::56:34');
Will 'parseDateString' method of dateformatter be useul here?
Thanks in advance.
You can use
DateField.StringToDate()
This is static function of DateField class, and returns Date object.

The string was not recognized as a valid datetime

objfile.dateFileDate=convert.ToDatetime(Format(txtdate.text,"MM/dd/yyyy hh:mm"))
following error is coming
The string was not recognized as a
valid datetime .There is an unknown
word starting at 0.
What should i do to save this datetime,
please help
You can't format normal text using datetime formats.
Try
C#
objfile.dateFileDate=DateTime.ParseExact(txtdate.text, "MM/dd/yyyy hh:mm", null);
VB.NET
objfile.dateFileDate=DateTime.ParseExact(txtdate.text, "MM/dd/yyyy hh:mm", Nothing)
This is assuming dateFileDate is a DateTime type and that the txtdate.text is in the above format.
If your program is used by a international crowd, read on :)
ppl from different cultures will write dates in diffrent formats, so if your always going to parse the string that could be get sticky. Consider using the calander control?
Im saying this based on personal experience.
Also finding out why your current one is failing, i would do a DateTime.Now.ToString() and compare that to whats in the textbox so you can see whats curently being typed in wrong ( While debugging off course, to help track down the problem)
Try hh:nn instead of hh:mm
I believe mm is Months in two digit format and nn is minutes in two digit format.

Resources