The row data of sfdatagrid is not displayed.
Video Link: https://www.syncfusion.com/downloads/support/forum/166178/ze/RowData-1331636418
Can you please share us below things?
Thanks for the update.
We are little unclear with your scenario. Can you please provide the more information related to your queries?
4. Provided the details or code snippet related to type of DataSource and DataSource binding in SfDataGrid
5. Provide replication procedure with video illustration of the reported problem
Hi
I'm still analyzing to fix this issue.
Here is my code snippet:
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
using (DataSet ds = (DataSet)e.Argument)
{
sfDataGrid.DataSource = ds.Tables[0];
ds.Tables[0].Dispose();
ds.Dispose();
}
}
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.Message, "Error");
return;
}
}
As you can see I am using backgroundWorker.
I checked e.Error.
Sometimes it works normally, and sometimes an error occurs like this.
But the code is the same.
My feeling is that this problem occurred when I used a large DataSet.
Using a small DataSet reduces this problem.
I need your help.
Regards,
Ki Hun.
Thanks for the update.
Based on provided information the data received in your is coming from another thread context than the UI thread, and that's the reason you see this error.
You can resolve the reported error by set the SfDataGrid.DataSource RunWorkerCompleted event in BackgroundWorker. Please refer the below code snippet,
|
backgroundWorker1.DoWork += backgroundWorker1_DoWork;
backgroundWorker1.RunWorkerCompleted += BackgroundWorker1_RunWorkerCompleted;
private void BackgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//set the result value to SfDataGrid.DataSource
sfDataGrid1.DataSource = e.Result;
if (e.Error != null)
{
MessageBox.Show(e.Error.Message, "Error");
return;
}
}
private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
using (DataSet ds = (DataSet)e.Argument)
{
//set the datasoure to result
e.Result = ds.Tables[0];
ds.Tables[0].Dispose();
ds.Dispose();
}
} |
Stack Overflow Link: https://stackoverflow.com/questions/10775367/cross-thread-operation-not-valid-control-textbox1-accessed-from-a-thread-othe
https://stackoverflow.com/questions/6481304/how-to-use-a-backgroundworker
Regards,
Vijayarasan S
Thank you.
I solved the problem in two ways.
1. Don't use BackgroundWorker.
2. Using your code snippet.
Both methods were successful.
Thank you very much for your help.
Regards,
Ki Hun
Thanks for the update.
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you😊.
Regards,
Vijayarasan S
- 7 Replies
- 2 Participants
- Marked answer
-
NK nam ki hun
- Jun 8, 2021 07:53 AM UTC
- Jun 25, 2021 10:03 AM UTC