This is a migrated thread and some comments may be shown as answers.

radGridview exceptions handle

4 Answers 181 Views
Visual Studio Extensions
This is a migrated thread and some comments may be shown as answers.
alok
Top achievements
Rank 1
alok asked on 16 May 2019, 06:31 AM

I add a textBox column and set dataType to system.Byte.

when type in cell letter throw system.FormatException.

how to handle this exception

 

 

4 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 16 May 2019, 09:09 AM
Hello Alok,

The user is allowed to type text with the GridViewTextBoxColumn and the text cannot be converted to Byte and this is why the exception occurs. It would be better to use GridViewDecimalColumn for this case:
var col = new GridViewDecimalColumn();
col.Maximum = 255;
col.Minimum = 0;
col.DataType = typeof(byte);
col.FieldName = "ByteColumn";
radGridView1.Columns.Add(col);

Please let me know if there is something else I can help you with. 
  
Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
alok
Top achievements
Rank 1
answered on 19 May 2019, 04:45 AM

Thank you dimitar so much

With this answer my problem has been resolved

0
alok
Top achievements
Rank 1
answered on 19 May 2019, 04:50 AM
Apart from this question, now how can radgridview exceptions be handle
0
Dimitar
Telerik team
answered on 20 May 2019, 11:15 AM
Hello Alok,

You can use the DataError event to handle exceptions that occur in the DataSource (e.g. ConstraintException). Such exceptions are handled by the grid and a message box will be displayed. The event allows you to handle this manually. Please note that this will not work for this case and you should always make sure that the user can add a proper values.

Please let me know if there is something else I can help you with. 

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Visual Studio Extensions
Asked by
alok
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
alok
Top achievements
Rank 1
Share this question
or