iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I have attached a modified example of this problem.
I have also attached a "before" and "after" screen shot of what is returned in my tests.
The line
TextBoxC.Text = WebInput3.Value.ToString();
returns an error because WebInput3.Value is null after the button is clicked.
There are several problems with this behavior.
1- The display "AfterEdit" is not correct. There are too many places after the decimal separator in each control.
2 - The value of WebInput3.Value is null after the button is clicked. It should be "1.4".
3 - When the page is refreshed and the focus is set to TextBox1, the value displayed/highlighted is "1.2". It should be "1,2".
4 - After entry, moving the cursor to TextBox2, the value displayed/highlighted is "1.3". It shouldb be "1,3". (Probably same issue as above).
5 - Please verify this is a problem in WebGrid, too.
Anyone looking at this? It ties together several problems about which I have been seeking information.
After carefully read your post on the other thread, I noted there are three important things to consider in your scenario.
Please allow me to assist you with this specific scenario. There are three steps that we need to do in order to implement this.
To display “3.14” as “3,14” in WebGrid
I created a simple sample of page that containing WebGrid and AccessDataSource control. The WebGrid is bind to “Products” table of Northwind.mdb through AccessDataSource control. The “Products” table has a column named “UnitPrice”. This column has decimal data type.
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" DataSourceID="AccessDataSource1" Height="600px" UseDefaultStyle="True" Width="800px"> <LayoutSettings AllowAddNew="Yes" AllowDelete="Yes" AllowEdit="Yes" AllowBatchUpdate="True" Culture="id-ID"> </LayoutSettings> <RootTable DataKeyField="ProductID"> <Columns> ... <ISWebGrid:WebGridColumn Caption="UnitPrice" DataMember="UnitPrice" DataType="System.Decimal" Name="UnitPrice" Width="100px" > </ISWebGrid:WebGridColumn> ... </Columns> </RootTable> </ISWebGrid:WebGrid> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Northwind.mdb" DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = ?" InsertCommand="INSERT INTO [Products] (..., [UnitPrice], ...) VALUES (..., ?, ...)" SelectCommand="SELECT * FROM [Products]" UpdateCommand="UPDATE [Products] SET ..., [UnitPrice] = ?, ... WHERE [ProductID] = ?"> <DeleteParameters> ... </DeleteParameters> <InsertParameters> ... </InsertParameters> <UpdateParameters> ... </UpdateParameters> </asp:AccessDataSource>
The screenshot below shows how the "UnitPrice" column displayed on browser.
First, I’m going to guide you to display “3.14” as “3,14” in WebGrid. In order to achieve this goal, we need to set the DataFormatString property of WebGrid instead of the DisplayFormat of WebInput. This is due to the fact that during data display, WebInput is not handling how the data is going to be displayed.
Since, we are going to display “3.14” as “3,14”, I will use “id-ID” as the culture of the control. The Indonesian culture has suitable numeric format with this requirement. It uses comma as the decimal separator and uses period as the thousand-grouping.
Following configuration will have WebGrid to show “3.14” as “3,14”.
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" ...> <LayoutSettings AllowAddNew="Yes" AllowDelete="Yes" AllowEdit="Yes" AllowBatchUpdate="True" Culture="id-ID"> </LayoutSettings> <RootTable DataKeyField="ProductID"> <Columns> ... <ISWebGrid:WebGridColumn Caption="UnitPrice" DataMember="UnitPrice" DataType="System.Decimal" Name="UnitPrice" Width="100px" DataFormatString="#,##0.00"> </ISWebGrid:WebGridColumn> ... </Columns> </RootTable> </ISWebGrid:WebGrid>
After apply DataFormatString, the "UnitPrice" column will looks as follow.
As may seen on the snippet code, the DataFormatString of WebGrid is set to "#,##0.00" instead of "#.##0,00". This property follows the .NET numeric format string. We need to define the digit placeholder; zero placeholder; group separator; and decimal point.
To display “3,14” during data editing
Next, we will integrate WebInput control into WebGrid. The WebInput will handle data editing. It will arrange the numeric format during data editing and enabling masking feature to help user entries/edits the numeric data.
Add following WebInput code.
<ISWebInput:WebInput ID="WebInput1" runat="server" Width="140px" DecimalSeparator=","> <HighLight IsEnabled="True" /> <EditFormat Format="#.##0,00##" IsEnabled="True" Type="Number"> <MaskInfo MaskExpression="#.##0,00##"> </MaskInfo> <ErrorWindowInfo IsEnabled="True"> </ErrorWindowInfo> </EditFormat> <CultureInfo CultureName="id-ID"> </CultureInfo> </ISWebInput:WebInput>
And modify the “UnitPrice” column into the following.
<ISWebGrid:WebGridColumn Caption="UnitPrice" DataMember="UnitPrice" DataType="System.Decimal" Name="UnitPrice" Width="100px" CustomEditorName="WebInputNET" CustomEditorServerId="WebInput1" EditType="Custom" DataFormatString="#,##0.00"> </ISWebGrid:WebGridColumn>
We need to set following property in order to have WebInput displays “3,14” during data editing.
The picture below shows when user edit on the cell of "UnitPrice".
To add custom currency symbol
Last thing, to add the currency symbol. Please modify the DataFormatString of “UnitPrice” column into the following.
<ISWebGrid:WebGridColumn Caption="UnitPrice" DataMember="UnitPrice" DataType="System.Decimal" Name="UnitPrice" Width="100px" CustomEditorName="WebInputNET" CustomEditorServerId="WebInput1" EditType="Custom" DataFormatString="Rp#,##0.00"> </ISWebGrid:WebGridColumn>
And set the EditFormat property of WebInput as follow.
<EditFormat Format="Rp#.##0,00##" IsEnabled="True" Type="Number"> <MaskInfo MaskExpression="Rp#.##0,00##"> </MaskInfo> <ErrorWindowInfo IsEnabled="True"> </ErrorWindowInfo> </EditFormat>
For your specific scenario, to add “^” as the currency symbol, I recommend you to set the culture of WebGrid and WebInput to a custom culture. For more detail information about how to create custom cultures, please check following article in here.
Please let us know whether this helps or not.
Questions:
1. Is it possible to do this without a mask? Masking input is not an option for us.
2. Is it possible to do this while assigning the culture during runtime (as in my example)? Your examples only use the culture "id-ID". My users have values stored that determine how they see numerics (Decimal and Group separators are user-selected, Currency Symbol is user-selected).
Problems:
1. When entering a value into a webinput field with the mask, the cursor jumps from the left-most marker to the first marker to the left of the decimal.
2. When pasting into a webinput field with a mask, the value is not pasted.
Will you send me your example above so I might demonstrate these problems in your example?
Please find the sample file in the attachment file.
Making the following changes to the form:
<form id="form1" runat="server"> <div> <ISWebGrid:WebGrid ID="WebGrid1" runat="server" DataSourceID="AccessDataSource1" Height="600px" UseDefaultStyle="True" Width="800px"> <LayoutSettings AllowAddNew="Yes" AllowDelete="Yes" AllowEdit="Yes" AllowBatchUpdate="True"> </LayoutSettings> <RootTable DataKeyField="ProductID"> <Columns> <ISWebGrid:WebGridColumn Caption="ProductID" DataMember="ProductID" DataType="System.Int32" Name="ProductID" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="ProductName" DataMember="ProductName" Name="ProductName" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="SupplierID" DataMember="SupplierID" DataType="System.Int32" Name="SupplierID" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="CategoryID" DataMember="CategoryID" DataType="System.Int32" Name="CategoryID" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="QuantityPerUnit" DataMember="QuantityPerUnit" Name="QuantityPerUnit" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="UnitPrice" DataMember="UnitPrice" DataType="System.Decimal" Name="UnitPrice" Width="100px" CustomEditorName="WebInputNET" CustomEditorServerId="WebInput1" EditType="Custom" DataFormatString="£#,##0.00"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="UnitsInStock" DataMember="UnitsInStock" DataType="System.Int16" Name="UnitsInStock" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="UnitsOnOrder" DataMember="UnitsOnOrder" DataType="System.Int16" Name="UnitsOnOrder" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="ReorderLevel" DataMember="ReorderLevel" DataType="System.Int16" Name="ReorderLevel" Width="100px"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Discontinued" DataMember="Discontinued" DataType="System.Boolean" Name="Discontinued" Width="100px"> </ISWebGrid:WebGridColumn> </Columns> </RootTable> </ISWebGrid:WebGrid> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Northwind.mdb" DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = ?" InsertCommand="INSERT INTO [Products] ([ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [UnitPrice], [UnitsInStock], [UnitsOnOrder], [ReorderLevel], [Discontinued]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" SelectCommand="SELECT * FROM [Products]" UpdateCommand="UPDATE [Products] SET [ProductName] = ?, [SupplierID] = ?, [CategoryID] = ?, [QuantityPerUnit] = ?, [UnitPrice] = ?, [UnitsInStock] = ?, [UnitsOnOrder] = ?, [ReorderLevel] = ?, [Discontinued] = ? WHERE [ProductID] = ?"> <DeleteParameters> <asp:Parameter Name="ProductID" Type="Int32" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="ProductID" Type="Int32" /> <asp:Parameter Name="ProductName" Type="String" /> <asp:Parameter Name="SupplierID" Type="Int32" /> <asp:Parameter Name="CategoryID" Type="Int32" /> <asp:Parameter Name="QuantityPerUnit" Type="String" /> <asp:Parameter Name="UnitPrice" Type="Decimal" /> <asp:Parameter Name="UnitsInStock" Type="Int16" /> <asp:Parameter Name="UnitsOnOrder" Type="Int16" /> <asp:Parameter Name="ReorderLevel" Type="Int16" /> <asp:Parameter Name="Discontinued" Type="Boolean" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="ProductName" Type="String" /> <asp:Parameter Name="SupplierID" Type="Int32" /> <asp:Parameter Name="CategoryID" Type="Int32" /> <asp:Parameter Name="QuantityPerUnit" Type="String" /> <asp:Parameter Name="UnitPrice" Type="Decimal" /> <asp:Parameter Name="UnitsInStock" Type="Int16" /> <asp:Parameter Name="UnitsOnOrder" Type="Int16" /> <asp:Parameter Name="ReorderLevel" Type="Int16" /> <asp:Parameter Name="Discontinued" Type="Boolean" /> <asp:Parameter Name="ProductID" Type="Int32" /> </UpdateParameters> </asp:AccessDataSource> <ISWebInput:WebInput ID="WebInput1" runat="server" Width="140px"> <HighLight IsEnabled="True" /> <EditFormat> <ErrorWindowInfo IsEnabled="True"> </ErrorWindowInfo> </EditFormat> </ISWebInput:WebInput> </div> </form>
And the codebehind:
protected void Page_Init(object sender, EventArgs e) { SetCulture(); } protected void Page_Load(object sender, EventArgs e) { CultureInfoWrapper CultWrap = new CultureInfoWrapper(); CultWrap.CultureInfo = SetCulture(); WebGrid1.LayoutSettings.Culture = CultWrap.CultureInfo; WebInput1.CultureInfo = CultWrap; WebInput1.DecimalSeparator = CultWrap.CultureInfo.NumberFormat.NumberDecimalSeparator; } private CultureInfo SetCulture() { // set "default" culture to en-US System.Globalization.CultureInfo projectCulture = new CultureInfo("en-US", false); // swap out decimal and grouping separators String numDecSep = ","; String numGrpSep = "."; // change the currency symbol String curSym = "£"; // change the date format String dtFormat = "yyyy/MM/dd"; //String dtMask = "####/##/##"; projectCulture.NumberFormat.NumberDecimalSeparator = numDecSep; projectCulture.NumberFormat.NumberGroupSeparator = numGrpSep; projectCulture.NumberFormat.CurrencyDecimalSeparator = numDecSep; projectCulture.NumberFormat.CurrencyGroupSeparator = numGrpSep; projectCulture.NumberFormat.CurrencySymbol = curSym; projectCulture.NumberFormat.CurrencyPositivePattern = 0; projectCulture.NumberFormat.CurrencyNegativePattern = 0; projectCulture.NumberFormat.PercentDecimalSeparator = numDecSep; projectCulture.NumberFormat.PercentGroupSeparator = numGrpSep; projectCulture.NumberFormat.PercentPositivePattern = 0; projectCulture.NumberFormat.PercentNegativePattern = 0; projectCulture.DateTimeFormat.ShortDatePattern = dtFormat; // how should long date/time be set? projectCulture.DateTimeFormat.LongDatePattern = "MMMM dd, yyyy"; projectCulture.DateTimeFormat.LongTimePattern = "HH:mm:ss"; // return culture so it can be set at control level return projectCulture; }
I am still having issues (see attached images).
Removing the mask allows me to enter the data as expected, but "somewhere" in the update process, the values are changed incorrectly.
<!>
Where do I set the decimal separator for the grid?
What is the culture used for "processing" the values in the grid?
How can I set the culture as I have done so it is actually used by the control?
If I set the decimal separator to a comma (",") on a form, it appears to be getting replaced if my thread culture has a different separator.
Thanks.
Thank you for the modified sample.
I’m currently still investigating this issue and need more time to provide you with solution, suggestion, or sample.I’ll get back to you as soon as possible.
Any progress on this?
Apologize for the delay in sending this.I will try to give you an update regarding this problem today.
Apologize for the delay in sending this.This problem has been forwarded to the development team. It is filed under work item #1077.
I will keep you updated with any news I heard from the team regarding work item #1077.
How do I research progress for "work item #1077"?
Work item #1077 is on progress.I will let you know when the nightly-build hotfix (pre-release hotfix) is ready to be evaluated.
This is still not working correctly. I've downloaded the latest available framework and webgrid.
Any ideas on when this might be fixed?
Anyone looking at this problem?
Apologize for the delay in sending this.
The hotfix is not available yet. We’ll see the possibility to have it released on the upcoming build version.
This is still a problem.When will you make the next build available?
When will you make the hotfix release available?
I sent you a message into your registered email account. Please check your inbox and let me know your response.
(from my email)
If it will help resolve the issue quicker, that would be good.
When you state you will "re-collect the information" does that mean you want me to define the problem again with specific examples or will you search the forum and gather that information.
All the information needed to identify and recreate the problem is in these cases:
In summary, the webinput and webgrid do not handle the display and use of culture information that is not set the same as the machine culture information.
When you state you will "re-collect the information" does that mean you want me to define the problem again with specific examples or will you search the forum and gather that information?
Thank you for the detail information, I will search the forum and gather the information.
I will update this thread as soon as possible.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname