1
Answer

There is no row at the position 2. C#

ZAIN ULARIFEEN

ZAIN ULARIFEEN

11y
2.7k
1
Hi experts...I am printing data from datagridview using dataadapter and dataset...but i m getting error like There is no row at position 2...plz help me how i have to handle this...thanks
 
I m getting error in this statement in the following code:
 
((DataTable)wddgv.DataSource).Rows[i + row];
  

private




void DrawGridBody(Graphics g, int y_value)


        {


           


int x_value;



           


for (int i = 0; i < 5; ++i)


            {


               


DataRow dr =


                         ((


DataTable)wddgv.DataSource).Rows[i + row];


                x_value = 0;



               


// draw a solid line


                g.DrawLine(


Pens.Black, new Point(0, y_value),


                       


new Point(this.Width, y_value));



               


foreach (DataGridViewColumn dc in wddgv.Columns)


                {


                   


string text = dr[dc.DataPropertyName].ToString();



                    g.DrawString(text,


this.Font, Brushes.Black,


                                             (


float)x_value, (float)y_value + 10f);



                    x_value += dc.Width + 5;


                }



                y_value += 40;


            }



            row += 5;


        }

Answers (1)
Next Recommended Forum