I want to pass DataGridviewRow
as a ref
where i am assigning some value to its cells but i am unable to do this
foreach(DataGridViewRow dgr in dgvMarksEntryByClassWise.Rows)
{
RowValueSet(ref dgr);
}
Here it is giving Compile time Error because dgr is an foreach iteration variable
Also i tried to do it with for loop
for (int i = 0; i < dgvMarksEntryByClassWise.Rows.Count; i++)
{
RowValueSet(ref dgvMarksEntryByClassWise.Rows[i]);
}
But here also it is giving Compile time error:
A property,indexer or dynamic member acces cannot passed as an out reference
I referd this question asked on above errors but did't Found any appropriate solution of my problem
- foreach iteration variable
- A property,indexer or dynamic member acces cannot passed as an out reference
Please Suggest me how to Do this
Update Code
void RowValueSet(ref DataGridViewRow dgr)
{
dgr.Cells["StudentZero"].Value = ss.Where(w => w.MarksheetMarks == "0").Count();
if (ss.Count() != 0)
dgr.Cells["StudentISEmpty"].Value = Convert.ToInt16(lblTotlatStudent1.Text) - ss.Count();
else
dgr.Cells["StudentISEmpty"].Value = 0;
dgr.Cells["StudentEntry"].Value = ss.Count();
}