Cannot add or edit rows

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top