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

Datagrid Null Values

How do I prevent the datagrid null values from showing up as "null" instead of just plain empty. I already have these codes.. dtgGrid.TableStyles.Add(dgtsSchool) dgtsSchool.MappingName = "FacultySchool" dgtsSchool.AlternatingBackColor = Color.AliceBlue dgtsSchool.GridColumnStyles(0).Width = 200 dgtsSchool.GridColumnStyles(2).Width = 250 I tried adding: Dim dte as New DataGridTextBoxColumn() dgtsSchool.GridColumnStyles.Add(dte) dte.NullText = "" But I'm getting an error adding the dte!

2 Replies

CB Clay Burch Syncfusion Team June 7, 2002 08:46 AM UTC

Try setting the DefaultValue member of the underlying DataTable.Columns element for the column. So, if you you an column whose mappingname is "textBody", then
	sqlDataAdapter1.Fill(this.dataSet11, "FAQEntries");
	this.dataGrid1.DataSource = this.dataSet11.Tables["FAQEntries"];
	DataTable dt = this.dataSet11.Tables["FAQEntries"];
	dt.Columns["textBody"].DefaultValue = "";


KF Konrad Ferguson July 1, 2002 01:51 PM UTC

I can't get the set DefaultValue thing to work for me but the following works for sure: 1.) We get an array of datarows from our dataTable. 2.) We go through each column in each cell in the column where we want to get rid of the 'null' 3.) Set each row's column to its string version - when it's 'null' the string version will be "", otherwise it will be what we want. If anyone finds a a more efficent way that works please let me know. ok, here's the code: DataRow[] drMyRow = dtMyDataTable.Select(); for(int i=0; i < numRecords; i++) { drMyRow[i].BeginEdit(); drPropName[i]["columnToEdit"] = drPropName[i]["columnToEdit].ToString(); drPropName[i].EndEdit(); }

Loader.
Live Chat Icon For mobile
Up arrow icon