0
Reply

in windows ap.insert runtime added textbox data in database.

dipak shah

dipak shah

Oct 4 2013 11:44 AM
1.1k
Respected Sir,friends......
" In c#.net winforms how to insert data in Database that are generated from dynamcally added textbox ?? "
below code generate multiple textbox,label and combobox.so please give me answer ...thanks in advanced..

  int t = 0,tr=0,t1=0,t2=0,com=0,com1=0,lbl=0,lbl1=0,lbl2=0,lbl3=0,lbl4=0;      
        int fr = 0;       
        public void meth()
        {              
                Label l = new Label();
                l.Name = "dyna_lbl" + lbl++;
                l.Location = new Point(0, 610 + (50 * lbl));
                this.Controls.Add(l);
               // panel3.Controls.Add(l);
                l.Text = label41.Text;

               TextBox rr = new TextBox();
                rr.Name = "dyna" + tr++;
                rr.Location = new System.Drawing.Point(100, 610 + (50 * tr));
                //r.Size = new System.Drawing.Size(200,25);    //for size of textbox  . 
                this.Controls.Add(rr);               
                rr.Text = "dyna" + tr;
                string s = rr.Text;
                textBox25.Text = s;

                Label ll = new Label();
                ll.Name = "dyna_lbl" + lbl1++;
                ll.Location = new Point(250, 610 + (50 * lbl));
                this.Controls.Add(ll);
                ll.Text = label39.Text;

                TextBox r = new TextBox();
                r.Name = "dyna" + t++;
                r.Location = new System.Drawing.Point(370, 610 + (50 * t));
                //r.Size = new System.Drawing.Size(200,25);    //for size of textbox  . 
                this.Controls.Add(r);
                // r.Text = r.Name; for getting name of textbox in textbox.

                Label l2 = new Label();
                l2.Name = "dyna_lbl" + lbl2++;
                l2.Location = new Point(490, 610 + (50 * lbl2));
                this.Controls.Add(l2);
                l2.Text = label38.Text;

                TextBox tt = new TextBox();
                tt.Name = "dyna" + t1++;
                tt.Location = new System.Drawing.Point(590, 610 + (50 * t1));
                // tt.Size = new System.Drawing.Size(200, 25);    //for size of textbox  . 
                this.Controls.Add(tt);

                Label l3 = new Label();
                l3.Name = "dyna_lbl" + lbl3++;
                l3.Location = new Point(750, 610 + (50 * lbl3));
                this.Controls.Add(l3);
                l3.Text = label40.Text;

                TextBox t3 = new TextBox();
                t3.Name = "dyna" + t2++;
                t3.Location = new System.Drawing.Point(850, 610 + (50 * t2));
                //  t3.Size = new System.Drawing.Size(200, 25);    //for size of textbox  . 
                this.Controls.Add(t3);

                Label l4 = new Label();
                l4.Name = "dyna_lbl" + lbl4++;
                l4.Location = new Point(970, 610 + (50 * lbl4));
                this.Controls.Add(l4);
                l4.Text = label37.Text;

                ComboBox cmb2 = new ComboBox();
                cmb2.Name = "dyna_cmb" + com1++;
                cmb2.Location = new System.Drawing.Point(1100, 610 + (50 * com1));
                this.Controls.Add(cmb2);

                cmb2.Items.Add("Bihar");
                cmb2.Items.Add("Rajsthan");
                cmb2.Items.Add("Uttar-Pradesh");
                cmb2.Items.Add("Madhya-Pradesh");
            }