We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problem with cell validation...

I'm using a GridDataBoundGrid and I've added a number of columns using the GridBoundColumn Collection Editor in VS.NET. One of the columns is bound to a floating point number and I'm trying to use the ValidateValue item to do automatic validation of cells in that column. I have set the item values as follows. NumberRequired = True Minimum = 0.01 Maximum = 24 Unfortunetly, this does not have any effect, I can still enter any value into the cells. Is there something else I need to do to get validation working? Thanks.

6 Replies

CB Clay Burch Syncfusion Team August 27, 2002 07:30 AM UTC

This appears to be a bug. Setting these values in the designer did not 'take'. We'll get this fixed. However, I was able to get these values to 'take' by explicitly setting them in an Form Load event handler with code such as: //C# this.gridDataBoundGrid1.GridBoundColumns["Quantity"].StyleInfo.ValidateValue = New GridCellValidateValueInfo(True, 0.01, 1000, "bad number") 'VB.NET Me.GridDataBoundGrid1.GridBoundColumns("Quantity").StyleInfo.ValidateValue = New GridCellValidateValueInfo(True, 0.01, 1000, "bad number")

SB Sheldon Barr August 27, 2002 10:23 PM UTC

Clay, thanks for the workaround, but there seems to be a problem indexing the GridBoundColumn by name. My GridBoundColumn is called 'hoursColumn' in the VS.NET designer and it is the 3rd column (index 2). The following code returns null. gridDataBoundGrid1.GridBoundColumns["hoursColumn"] Whereas this code returns the correct column object. gridDataBoundGrid1.GridBoundColumns[2] I'm using this as a workaround to my problem, hope this makes sense.

CB Clay Burch Syncfusion Team August 28, 2002 08:16 AM UTC

Is "hoursColumn" the MappingName for your GridBoundColumn, or is it the HeaderText? Is it also the exact case? Thanks

SB Sheldon Barr August 29, 2002 03:12 AM UTC

Ok, "hoursColumn" is the design name of the column. I tried using the HeaderText of the column and that worked. I seem to have run into another problem though. The AllowEnter attribute doesn't seem to work whether I set it through the designer or directly in code. I have a column "notesColumn" with CellType=TextBox and AllowEnter=false but the column still allows newlines to be entered. What's more, the previous column is the "hoursColumn" I described earlier, has AllowEnter=false, and pressing enter correctly moves the cursor to the next column but inserts a newline there. I have ActivateCurrentCellBehaviour=SelectAll set for the table so this also has the unhappy side-effect of deleting the text in the "notesColumn". I'd appreciate any guidance you could give me.

CB Clay Burch Syncfusion Team August 29, 2002 07:08 PM UTC

Sheldon, I tried to see this behavior in the attached simple sample. The first 2 columns are text columns and they both have AllowEnter = False, but I don't see this problem. Maybe you could spot some difference between this sample and what you are doing? Clay

TL Tom Le Blanc November 14, 2002 05:55 PM UTC

Is there any way to short-circut the ValidateValue.NumberRequired to allow for an empty cell? e.g. If a user enters a value in a validated cell and realizes it's the wrong cell, but doesn't want a zero in the cell. Do you have any sample code (VB preferred) on how to roll that using the GridCellValidateValueInfo? Thanks, Tom

Live Chat Icon For mobile
Up arrow icon