Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to refresh the Datagridview after adding a row

$
0
0

Hi,

I have a datagridview (dgv) which allows users to add rows on the fly. I have an ID field which is an auto-increment field, after the curAdapter.Update row (as seen below) is executed, the grid's ID field is still null. How can I get the grid refreshed with the new ID while keeping all the settings that I had setup initially?

'Initial settings

            dgv.DataSource = curBindingSource
            curAdapter = New SqlDataAdapter(selectCommand, connectionstring)
            Dim commandBuilder As New SqlCommandBuilder(curAdapter )          
            curAdapter.Fill(curTable)
            curBindingSource.DataSource = curTable

'then add combobox columns, reordering the columns

'Update

curAdapter.Update(CType(Me.curBindingSource.DataSource, DataTable))

Thanks in advance. Your help is greatly appreciated!


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>