Can I turn off commas in WebNumbericEditor?
Gary
Hello GaryWhat you are asking is connected with the culture used in the WNE . When you select the editor go to its properties (right click when in design view and the last option is Properties) and go to the Culture property. The default culture separates the number with a comma per three digits counted from the tale cause it is en-US or some other culture which uses this styling for big numbers. You can modify the separators in your current culture the following way:protected void Page_Load(object sender, EventArgs e)
{
CultureInfo ci = Thread.CurrentThread.CurrentCulture;
WebNumericEditor1.Culture = new CultureInfo(ci.Name);
WebNumericEditor1.Culture.NumberFormat.NumberGroupSeparator = "";
}
If you have more questions about this issue do not hesitate to ask.
Nikifor,
This works fine for a stand-alone numeric editor controls, but what about one in a webgrid?? The only way for this to work is to somehow tap into an event that occurs after the grid is loaded and bound with data.... Exactly how would one do this? I tried using the DataBound event of the web grid but that only bound the row, nothing was in the columns....
It would be much better if you guys were to add a parameter to the web numeric editor control to specify formatting of the data to the user (show/don't show commas, etc). As it is, changing the culture for every web numeric control is really hokey.
In the meantime, how can we accomplish this (i.e. show the numeric integer without commas) now with the web numeric editor?
-Tom
Hello Tom,Here is a sample which demonstrates how to set the culture to a WNE in code behind. This setting is kept when postback occurs. Please take a look at the sample.
Unfortunately, I had already tried using the InitializeRow event. That event only seems to run the first time the web form is loaded; on a repost it doesn't run. So what happens is that the commas go away the first time, but if I have a validation error in the form, and a repost occurs (and the datatable gets rebound to the grid), then the commas show up again. To double check I used your code as it is in my project and that occurred each time.
Is there another event that gets run each and every time a repost/rebind occurs? If so, what code needs to go there?
Hello Tom, Every time the grid is rebound the InitializeRow Event is fired. Also please specify what validation do you have - server or client one? I need more details on how the invalid page makes postback. The behavior with not firing InitializeRow after rebinding the grid seems not to be reproducible with the sample i attached.
Never mind, I am an idiot! Turns out I was binding improperly on the post back; that is why the InitializeRow was not being fired. I am surprised it worked at all.
Anyway, we are set, the InitializeRow event works fine. But I still think having this embedded in the control will save code and time.
Thanks!
-Tom S
Hello SimpTheChimp,I already logged a feature request in the another support ticket you have opened regarding the issue.