Wisej 2.2.3 NULL is returned when getting Rows of dataGridView

Answered
0
0

In Wisej 2.1.86, the program source that was operating normally is
Bind DataTable to dataGridView in Wisej 2.2.3 Beta
If you try to get the connected data with foreach, all is NULL
The value will be returned.
Please check with that person.

Below is the tested program source.
————————————————– ———————————
DataTable wTable = new DataTable(“Table”);

// Column Name Add
wTable.Columns.Add(“Subject”);
wTable.Columns.Add(“Score”, Type.GetType(“System.Int32”));
wTable.Columns.Add(“Name”);
wTable.Columns.Add(“Class”);

wTable.Rows.Add(“Math”, 80, “Name1”, “A”);
wTable.Rows.Add(“Math”, 50, “Name2”, “B”);
wTable.Rows.Add(“Math”, 90, “Name3”, “A”);

BindingSource wBindingSource = new BindingSource
{
DataSource = wTable
};
this.dataGridView1.DataSource = wBindingSource;
this.dataGridView1.Refresh();

foreach (DataGridViewRow wDataRow in this.dataGridView1.Rows)
{
System.Console.Write(wDataRow.Cells[“Subject”].Value); //<—- NULL is returned
}
————————————————– ———————————

  • Luca (ITG)
    BTW, no need to call datagrid1.Refresh().
  • You must to post comments
Good Answer
0
0

The issue is the enumeration because of the new row virtual system. It will be fixed in the next beta update. You can try this:

for (var i = 0; i < this.dataGridView1.RowCount; i++)
{
  var wDataRow = this.dataGridView1.Rows[i];
  System.Console.Write(wDataRow.Cells["Subject"].Value);
}

Additionally note that requesting a DataGridViewRow through this.dataGridView1.Rows[i] or the enumeration (when fixed) it will cause the virtual row to become real (to be created). A better way is to use this.dataGridView1.GetValue() and this.dataGridView1.SetValue(); these methods don’t force the creation of the DataGridViewRow.

  • You must to post comments
0
0

Takao,

we have just uploaded a new Wisej beta release (2.2.4) that fixes this issue.

Best regards
Frank

  • Takao Watanabe
    Thank you. Correct program source in 2.2.4 I confirmed that it works.
  • You must to post comments
0
0

Luca (ITG)

OK.
Wait for the next release.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.