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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Allow null value in date cell (GDBG)

Thread ID:

Created:

Updated:

Platform:

Replies:

73126 Apr 21,2008 03:11 PM UTC May 23,2008 07:01 AM UTC WinForms 3
loading
Tags: GridControl
Martin
Asked On April 21, 2008 03:11 PM UTC

After upgrading to version 6.2.0.32, I cannot delete a date from a GDBG field. When I delete a date and leave the cell, I get the message that the value is not a valid DateTime.
Property AllowDBNull of the corresponding DataColumn is set to true.

This also happens in your example GDBGcombos when for example I try to delete an order date from the order table.

What do I have to do?

Thanks in advance,
Martin


M.Tölle
Replied On April 25, 2008 07:16 AM UTC

Hi,

the issue exists also for int cellvaluetype and i found no solution. This seems to be a bug!

bye
m.tölle



>After upgrading to version 6.2.0.32, I cannot delete a date from a GDBG field. When I delete a date and leave the cell, I get the message that the value is not a valid DateTime.
Property AllowDBNull of the corresponding DataColumn is set to true.

This also happens in your example GDBGcombos when for example I try to delete an order date from the order table.

What do I have to do?

Thanks in advance,
Martin




Sri Rajan [Syncfusion]
Replied On April 28, 2008 11:50 PM UTC

Hi Martin,

You need to handle CurrentCellValidating and DrawCellDisplayText events to solve this issue. In currentCellValidating event, you should assign the Renderer.ControlValue to DateTime.MinValue if the ControlText is String.Empty and store the current cell location in Hashtable. In DrawCellDisplayText event, you need check the cell location with that Hashtable, if it presents then set e.DisplayText to String.Empty. Here is the sample code that shows this task.


void gridDataBoundGrid2_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
int RowIndex = e.Style.CellIdentity.RowIndex;
int ColIndex = e.Style.CellIdentity.ColIndex;
if (EmptyDateCell.Contains(GetHashCode(RowIndex, ColIndex)))
{
bool eValue = (bool)EmptyDateCell[GetHashCode(RowIndex, ColIndex)];
if (eValue)
{
e.DisplayText = String.Empty;
}
}
}
Hashtable EmptyDateCell = new Hashtable();
void gridDataBoundGrid2_CurrentCellValidating(object sender, CancelEventArgs e)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid;
GridCurrentCell cc = grid.CurrentCell;
if (grid.Binder.InternalColumns[cc.ColIndex - 1].MappingName == "OrderDate" || grid.Binder.InternalColumns[cc.ColIndex - 1].MappingName == "RequiredDate" || grid.Binder.InternalColumns[cc.ColIndex - 1].MappingName == "ShippedDate")
{
if (cc.Renderer.ControlText == String.Empty)
{
cc.Renderer.ControlValue = DateTime.MinValue;
grid.Model[cc.RowIndex, cc.ColIndex].CellValue = DateTime.MinValue;
EmptyDateCell[GetHashCode(cc.RowIndex, cc.ColIndex)] = true;
grid.Binder.EndEdit();
}
else
{
EmptyDateCell[GetHashCode(cc.RowIndex, cc.ColIndex)] = false;
}
}
}
private string GetHashCode(int RowIndex, int ColIndex)
{
return "#" + RowIndex + "#-#" + ColIndex + "#";
}



Sample:
http://websamples.syncfusion.com/samples/Grid.Windows/F73126/main.htm

Please let me know if this helps.

Best Regards,
Srirajan



Administrator [Syncfusion]
Replied On May 23, 2008 07:01 AM UTC

Hi Srirajan,

yes this helps, thank you very much.

Best Regards
Martin


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;