Link to home
Start Free TrialLog in
Avatar of aspgeek
aspgeek

asked on

how to pass a control textbox and list array as parameters

I have two methods one whihc will create the array of textboxes and labels and teh other whihch will insert values into the arrays of labels and textboxes.I need to know how to pass teh array as a parameter to the filldata methos.  Please advise ASAP.


I  public void createcontrols( string table_name)
    {
        
      .............
         Label[] lbls1 = new Label[count];
       TextBox[] text_bx = new TextBox[count];
 
        int i = 0;
        while(i<count)
        {
            lbls1[i] = new Label();
            this.Controls.Add(lbls1[i]);
            i++;
        }
      i = 0;
      while (i < count)
      {
          text_bx[i] = new TextBox();
          this.Controls.Add(text_bx[i]);
          i++;
      }
 
    }
 public void filldata()
    {
 
        int j = 0;
        foreach (DataRow row in ds_tablespecs.Tables[0].Rows)
        {   
            HtmlTableRow htr_rowlbl = new HtmlTableRow();
            HtmlTableCell htc_ctrllbl = new HtmlTableCell();
            lbls1[j].Text = row["COLUMN_NAME"].ToString();
            htc_ctrllbl.Controls.Add(lbls1[j]);
            htr_rowlbl.Cells.Add(htc_ctrllbl);
            labels.Controls.Add(htr_rowlbl);
            
           //switch (ctrltype)
           //{
           //    case "DATE": 
           //        break;
 
           //    case "NUMBER": Console.WriteLine("HELLO");
           //        break;
 
           //    default:
           //        Console.WriteLine("NONE OF THE OPTIONS");
           //        break;
           //}
 
                HtmlTableRow htr_rowctrl = new HtmlTableRow();
            HtmlTableCell htc_ctrlctrl = new HtmlTableCell();
           string ctrltype = row["DATA_TYPE"].ToString();
             //TextBox txt_bx = new TextBox();
            text_bx[j].Text=  row["DATA_TYPE"].ToString();
            htc_ctrlctrl.Controls.Add(text_bx[j]);
            htr_rowctrl.Cells.Add(htc_ctrlctrl);
            controls.Controls.Add(htr_rowctrl);
            string col_null = row["NULLABLE"].ToString();
            //if (col_null == "Y")
            //{
            //    RequiredFieldValidator rv = new RequiredFieldValidator();
            //    rv.ControlToValidate = "txt_bx";
            //    htc_ctrlctrl.Controls.Add(rv);
            //    htr_rowctrl.Cells.Add(htc_ctrlctrl);
            //    controls.Controls.Add(htr_rowctrl);
            //    rv.Enabled = true;
            //    rv.ErrorMessage = "PLEASE FILL TEH TEXT BOX";
 
            //}
            j++;
      }
     }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of cauos
cauos

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial