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

Datagrid Null Values

Thread ID:

Created:

Updated:

Platform:

Replies:

342 Jun 7,2002 03:16 AM Jul 1,2002 09:51 AM Windows Forms 2
loading
Tags: FAQ
quilla_b
Asked On June 7, 2002 03:16 AM

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 04:46 AM

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 09:51 AM

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(); }

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.

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.

;