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 SimpTheChimp,I already logged a feature request in the another support ticket you have opened regarding the issue.
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
It's pretty simple... The page runs the first time, the data is retrieved, bound to the webgrid - and the InitializeRow is fired - and then displayed to the user. I have both server and client validations - of course, I know the client validations don't cause a post back; they are not the problem.
So I fill out some things on the form, and press my Submit button which causes a post back. The data is retrieved from session state, rebound to the grid, and then my submit button logic takes over. In there I determine that there was an issue with the data they submitted, so I set an error message to display on the screen and then redisplay the form. In is in this post back that I find the InitializeRow doesn't fire. I know that because I set a breakpoint on the first line of the InitializeRow line and it never fires during the repost. Therefore when the grid re-displays, the numeric editor now has commas in-between the characters.
Hopefully that helps. Is there something special I need to do during the rebind to the web grid to get the InitializeRow to fire?
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.
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?