Suppress zeros

What''s the best way to suppress zero''s in a griddataboundgrid? I tried this: ''NettoPrice col = Me.myGrid.Binder.NameToColIndex("ArticlePrice") If col > -1 Then Dim dt As DataTable = CType(Me.myGrid(1, col).DataSource, DataTable) For i As Integer = 2 To dt.Rows.Count - 1 dt.Rows(i)(0) = IIf(dt.Rows(i)(0).ToString() = "0", String.Empty, dt.Rows(i)(0).ToString()) Next End If But that doesn''t seem to work.

2 Replies

AD Administrator Syncfusion Team October 22, 2004 06:55 AM UTC

You can do this dynamically in DrawCellDisplayText. This way you do not modify the actual datatable values, but instead just change what the grid displays.
private void gridDataBoundGrid1_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
	int col = e.Style.CellIdentity.ColIndex;
	if(this.gridDataBoundGrid1.Binder.NameToColIndex("Col2") == col)
	{
		if(e.DisplayText == "0")
		{
			e.DisplayText = "";
			e.Cancel = true;
		}
	}
}


AD Administrator Syncfusion Team October 22, 2004 07:36 AM UTC

Thanks, that did the trick!

Loader.
Up arrow icon