简体   繁体   中英

C# Adding new rows in DataGridView and database (Access)

I am working on a billing form and i plan to do it in DataGridView to display the Item Name, Quantity, Price, etc. In addition to that, I also intend to add button controls such as snacks and drinks, which would automatically add rows into the DataGridView when selected. My DataGridView is binded to a DataSource. My question is, how do i go about achieving (a) Automatically adding rows into DataGridView after selecting a Beverage from any Beverage button and (b) Inserting these records into the database as well. Any sort of guidance will be greatly appreciated, cheers! :)

Create a Datatable dynamically make it as datasource

Check this link for creating datatable dynamically

after creating it add

datagrid.DataSource=dt;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM