Hi
After fetching information from the database and performing calculations, I want to add the information to the data grade view.
I have already made the columns based on the data type
I get this error when running the program:
"Rows can not be add programmatically added to the rad radgridview's Rows collection when the control is data-bound"
This error does not always occur and it happens by accident
Whatever I searched for, I did not find the reason
Maybe my solution to this is wrong
Thank you in advance for your support
This code snippet is inside a loop and may run hundreds of times :
var item = new GridViewDataRowInfo(dailyGridView.MasterView);
if (dailyGridView.Columns.Any(c => c.Name == "Code"))
item.Cells["Code"].Value = personelInfo.First().Code;
if (dailyGridView.Columns.Any(c => c.Name == "FirstName"))
item.Cells["FirstName"].Value = personelInfo.First().FirstName;
if (dailyGridView.Columns.Any(c => c.Name == "LastName"))
item.Cells["LastName"].Value = personelInfo.First().LastName;
if (dailyGridView.Columns.Any(c => c.Name == "Date"))
item.Cells["Date"].Value = PersianDateTime.FromDateTime(report.Date).ToShortDateString();
if (dailyGridView.Columns.Any(c => c.Name == "DayName"))
item.Cells["DayName"].Value = PersianDateTime.FromDateTime(report.Date).DayName;
And more line ...
dailyGridView.Rows.Add(item);