Question Data Grid Formatting

cheekcn

New member
Joined
Mar 8, 2010
Messages
1
Programming Experience
5-10
I cannot figure out why the following code won't format my data grid. I was hoping that another set of eyes might be able to help me find the error.

Dim conn As SqlConnection = New SqlConnection("Data Source=xxxxx;Initial Catalog=xxxxx;User ID=xxxxx;")
Dim dataAdapter As SqlDataAdapter = New SqlDataAdapter("Select ID, Description, MfgNum, ProductSize from AT_Product", conn)
Dim dt As DataTable = New DataTable()
dataAdapter.Fill(dt)

DataGrid1.DataSource = dt

Dim tableStyle As New DataGridTableStyle()
tableStyle.MappingName = "AT_Product"

'MfgNum
Dim column As New DataGridTextBoxColumn()
column.MappingName = "MfgNum"
column.HeaderText = "Mfg #"
column.Width = 70
tableStyle.GridColumnStyles.Add(column)

'Item Description
column = New DataGridTextBoxColumn()
column.MappingName = "Description"
column.HeaderText = "Description"
column.Width = 140
tableStyle.GridColumnStyles.Add(column)

'Size
column = New DataGridTextBoxColumn()
column.MappingName = "ProductSize"
column.HeaderText = "Size"
column.Width = 70
tableStyle.GridColumnStyles.Add(column)

Me.DataGrid1.TableStyles.Add(tableStyle)
 
Back
Top