how to DataGridTextBoxColumn to format the column
I would need to format a column "contact" to display only part of the field from the database, but I got an error like this:
object reference not set to an instance of object.
this is part of my code:
'create a data adapter
da = New SqlDataAdapter(strQuery, dbSQLConnection)
'create a new dataset
ds = New DataSet
'fill dataset
da.Fill(ds)
DataGrid1.DataSource = ds.DefaultViewManager
'this is where the problem is
Dim dgt As DataGridTextBoxColumn = CType (DataGrid1.TableStyles("OrHeader").GridColumnStyle s("contact"), DataGridTextBoxColumn)
Dim index As Integer
index = dgt.Format.IndexOf(",")
dgt.Format.Substring(index)
can anyone tell me where I did wrong? Thank you!
|