Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i make a null field show up blank in the datagrid? 3

Status
Not open for further replies.

Blitz

Technical User
Jul 7, 2000
171
US
currently when a dataset contains a null value the datagrid displays (Null) is there any way to make it just be blank and not show (Null)? TIA
 
Here is what I used when I needed to have zero-length strings instead of NULL in a Dataset. It also deletes a row if it consists entirely NULL Strings.

Public Shared Sub _
SetIsNullStringsToEmpty( _
ByVal DataSet As DataSet)
' Set every Type(string) Item that ISnull to String.Empty
Dim dt As DataTable
Dim dc As DataColumn
Dim dr As DataRow
Dim I, J, K As Integer
Dim blnAllNull As Boolean

Dim sName As String = String.Empty
For I = 0 To DataSet.Tables.Count - 1
dt = DataSet.Tables(I)
' Go Backwards for RemoveAt
For J = dt.Rows.Count - 1 To 0 Step -1
dr = dt.Rows(J)
blnAllNull = True
For K = 0 To dr.Table.Columns.Count - 1
' Get Coulumn
dc = dr.Table.Columns(K)
sName = dc.ColumnName
If dc.DataType Is GetType(String) Then
If dr.IsNull(dc.Ordinal) Then
dr.Item(dc.Ordinal) = String.Empty
Else
blnAllNull = False
End If
Else
blnAllNull = False
End If
Next
If blnAllNull Then
dr.Table.Rows.Remove(dr)
End If
Next
Next
End Sub


Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Here is what i used;

Dim ts As New DataGridTableStyle()
ts.MappingName = "nameOfTheTableInDatasetWitchGridUsesAsDataSource"
Me.grddate.TableStyles.Clear()
Me.grddate.TableStyles.Add(ts)
ts.GridColumnStyles("ColumnName").NullText = " "
in column ColumnName it puts " " instead of null
 
Cool. Too bad there isn't one for the DataColumn. I get my data returned as XML from a BizTalk server, put it into a strongly typed DataSet with the ReadXML method and process from there.

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top