S
Scott Adams
I have a datagrid bound to a single table that I want users to be able to
add new rows and edit existing rows. My problem occurs when I apply custom
formatting to my columns. Consider the following code:
cn = New SqlConnection(SQL_CONNECTION_STRING)
da = New SqlDataAdapter("SELECT * FROM table_name", cn)
cb = New SqlCommandBuilder(da)
ds = New DataSet
da.Fill(ds, "table_name")
MyDataGrid.DataSource = ds.Tables("table_name")
The above block will allow the functionality I wish to create. If I apply
the next block of code (formatting one of the DataGridTextBoxColumns), I can
no longer add or edit rows.
Dim grdTableStyle1 As New DataGridTableStyle()
grdTableStyle1.MappingName = "table_name"
Dim grdColStyle1 As New DataGridTextBoxColumn()
grdColStyle1.HeaderText = "Header Text"
grdColStyle1.MappingName = "field_name"
grdTableStyle1.GridColumnStyles.AddRange (New DataGridColumnStyle()
{grdColStyle1})
Me.grdTransit.TableStyles.Add(grdTableStyle1)
Thanks in advance for the suggestions.
add new rows and edit existing rows. My problem occurs when I apply custom
formatting to my columns. Consider the following code:
cn = New SqlConnection(SQL_CONNECTION_STRING)
da = New SqlDataAdapter("SELECT * FROM table_name", cn)
cb = New SqlCommandBuilder(da)
ds = New DataSet
da.Fill(ds, "table_name")
MyDataGrid.DataSource = ds.Tables("table_name")
The above block will allow the functionality I wish to create. If I apply
the next block of code (formatting one of the DataGridTextBoxColumns), I can
no longer add or edit rows.
Dim grdTableStyle1 As New DataGridTableStyle()
grdTableStyle1.MappingName = "table_name"
Dim grdColStyle1 As New DataGridTextBoxColumn()
grdColStyle1.HeaderText = "Header Text"
grdColStyle1.MappingName = "field_name"
grdTableStyle1.GridColumnStyles.AddRange (New DataGridColumnStyle()
{grdColStyle1})
Me.grdTransit.TableStyles.Add(grdTableStyle1)
Thanks in advance for the suggestions.