Skip to content

System.NullReferenceException

alperen aydin

Asked Feb 27, 2011, 8:35 AM EST4 answers
Share
LinkedInX
Hi;

I get the above exception in this code line.

DataGridView1.Rows[iIndex].Cells[1].Value = iGLCount.ToString();

datagridview is defined in the Designer.cs i dont think i need the Troubleshooting tip "Use the 'new' keyword to create an object instance"

in some forums i did read that i can not modify/set cells directly so i shoul enable the edit mode like ;

DataGridView1.BeginEdit();  and i got nada.

Any ideas ?

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Suthish Nair
    0
    On which event you using below logic.
    0
  • 0
    button click :) Thanks neway Suthish i got it covered.i realized i can not set the cell values directly.
    0
  • Suthish Nair
    0
     great to hear that, can you share with us also.
    0
  • 0
    actually i get the datas from different source so i thought i could set the cells 1 by 1. As i mentioned i realised i can not do that i defined an array of strings like : value[0] =sourcevalue1; value[1] = sourcevalue2; . . . and then add them to the datagridview with insert method like : DataGridView.Rows.Insert(index,value);
    0