venus najad

venus najad

  • 1.3k
  • 414
  • 29k

how to fill a 2D panel in c# asp net webform

Aug 18 2024 8:27 PM

hello every one

i will fill a 2D panel  dynmically.

i have tried but i receive this error: Object reference not set to an instance of an object.

i have initialized the controls as following and try to fill the panel:

row=0, col=0;

HtmlForm form2 = new HtmlForm();            
            Panel[,] panelAd = new Panel[mm, 3];
            Table mytable = new Table();   

...

 mytable.Controls.Add(trow_7);

if (col < 3)
            {
                panelAd[row, col].Controls.Add(mytable);
                this.form2.Controls.Add(panelAd[row, col]);
            }
            else
            {
                row++;
                col = 0;
                panelAd[row, col].Controls.Add(mytable);
                this.form2.Controls.Add(panelAd[row, col]);
            }
            

how should i fix the error? on panelAd[row, col].Controls.Add(mytable); in if statement.

appreciate your respond with codes, kind regards

 


Answers (1)