SyncFusion GridDataBoundGrid DataBinding Issue
I am using Syncfusion's GridDataBoundGrid control and binding my custom List. One of the properties is Nullable DateTime (DateTime?). When I add a new row to the grid and started editing in the DateTime开发者_如何学编程 column, If I type Alphanumeric, A message box displays some thing like "XX is not a valid value for Nullable '1". 1. How do I handle this to put some more meaningful maessage?
I would appreciate the solution.
Use DirectSaveCellInfo
property to save once you complete editing a cell.
this.gridDataBoundGrid1.Binder.DirectSaveCellInfo = true;
The CurrentCellErrorMessage event will be triggered before showing the error message. You can handle this event and show your custom MessageBox and cancel the event. Also you can set your custom text to the Text property. The following code shows the implementation of the same.
private void Form1_Load(object sender, EventArgs e)
{
this.gridDataBoundGrid.CurrentCellErrorMessage += new GridCurrentCellErrorMessageEventHandler(gridDataBoundGrid_CurrentCellErrorMessage);
}
void gridDataBoundGrid_CurrentCellErrorMessage(object sender, GridCurrentCellErrorMessageEventArgs e)
{
//e.Text = "My Text";
MessageBox.Show("Type your custom message here. The original text is: \"" + e.Text+ "\"");
e.Cancel = true;
}
精彩评论