When I change a value in a cell the record is updated via a SQL Insert statement which works fine. When I don't change a value in a cell and just tab to the next cell, it removes all the current rows from the datagridview and renders a new row.
Loading
Sachin SinghPosted Jan 8, 2024, 3:50 PM
Test if this works
Naimish MakwanaPosted Jan 8, 2024, 12:07 PM
It seems like you’re experiencing an unusual behavior with your DataGridView. This could be due to a variety of reasons, and without more specific details about your implementation, it’s hard to pinpoint the exact cause. However, here are a few general suggestions that might help:
Data Binding: Ensure that your DataGridView is properly bound to a data source. Adding rows one by one can lead to performance issues1. Instead, consider using a
BindingSourceor creating aDataTableand passing the data reader to itsLoadmethod1.Event Handling: Check your event handlers, especially those related to cell or row changes. An event might be triggering the removal and addition of rows unintentionally.
Debugging: Use debugging tools to step through your code and see where the issue might be occurring. This can help you understand if there’s a particular method or event causing the problem1.
Data Updates: Make sure that updates to your data source are being correctly reflected in your DataGridView. If you’re using a SQL Insert statement to update records, ensure that this operation is successful and that your DataGridView is refreshed afterwards to reflect these changes.
Here's a general example in C# using WinForms to demonstrate updating instead of inserting:
Thanks
Pushpendra ShuklaPosted Jan 8, 2024, 11:57 AM
use update panel for showing updating records. your records are removed due to page refresh that why recodrs are distory.
you should be use repeater or datagrid both under the UpdatePanel .
// your data grid
UpdatePanel>