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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Datagrid Null Values

Thread ID:





342 Jun 7,2002 07:16 AM UTC Jul 1,2002 01:51 PM UTC WinForms 2
Tags: FAQ
Asked On June 7, 2002 07:16 AM UTC

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!

Clay Burch [Syncfusion]
Replied On 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 = "";

Konrad Ferguson
Replied On 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(); }


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon