Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 2nd, 2008, 10:30 PM
Registered User
 
Join Date: Jan 2008
Location: , , India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to store the dynamically generated controls ?

I have generated controls now i want to store those controls and also want to store the user's input enetered in the generated controls into the database.How to do it.Code is appreciated(C#).Below is the code given to generate dynamic controls on each button click.

protected void Button4_Click(object sender, EventArgs e)
    {

        Panel3.Visible = true;
        T = "U";
        try
        {

            StreamWriter writer = File.AppendText(@"C:\asp\f.txt");
            writer.WriteLine("U");
            writer.Close();
        }
        catch (IOException io)
        {
            throw new IOException(io.Message);
        }


        k++;
        Addit();

        T = "";

        k1 = k1 + 1;


    }
    protected void Button6_Click(object sender, EventArgs e)
    {

        Panel5.Visible = true;
        T = "C";

        try
        {

            StreamWriter writer = File.AppendText(@"C:\asp\f.txt");
            writer.WriteLine("C");
            writer.Close();
        }
        catch (IOException io)
        {
            throw new IOException(io.Message);
        }


        k++;
        Addit();

        T = "";

        k1 = k1 + 1;

    }
protected void Button10_Click(object sender, EventArgs e)
    {

        Panel7.Visible = true;
        T = "T";
        try
        {

            StreamWriter writer = File.AppendText(@"C:\asp\f.txt");
            writer.WriteLine("T");
            // File.GetCreationTime();

            writer.Close();

        }
        catch (IOException io)
        {
            throw new IOException(io.Message);
        }

        k++;
        Addit();

        T = "";

        k1 = k1 + 1;

    }
 public void Addit()
    {


        try
        {
            string ln;
            int i = 0;
            StreamReader tr = new StreamReader(@"C:\asp\f.txt");
            ln = tr.ReadLine();
            while (ln != null)
            {
                // Response.Write(ln);
                if (ln == "T")
                {

                    string s = string.Empty;
                    l = new Label();
                    t = new TextBox();

                    //s=name[(k-1)];
                    s = "l";
                    s += i.ToString();
                    l.ID = s;
                    //l.Font.Bold = true;
                    l.Style["Position"] = "Absolute";
                    //l.Style["Top"] = "25px";
                    l.Style["Left"] = "10px";
                    //l.Style.Add["bold", "true"];
                    l.Text = TextBox11.Text;
                    l.EnableViewState = true;
                    //l.EnableViewState = false;
                    s = string.Empty;
                    s = "t";
                    s += i.ToString();
                    t.ID = s;
                    s = string.Empty;
                    s = "Text";
                    s += i.ToString();
                    //t.Text = s;
                    t.Style["Position"] = "Absolute";
                    //t.Style["Top"] = "25px";
                    t.Style["Left"] = "100px";
                    t.EnableViewState = true;
                    //t.EnableViewState = false;
                    LiteralControl lc = new LiteralControl();
                    lc.Text = "<BR><BR>";
                    Panel4.Controls.Add(l);
                    Panel4.Controls.Add(t);
                    Panel4.Controls.Add(lc);


                }
                else if (ln == "U")
                {
                    string s = string.Empty;
                    l2 = new Label();
                    t2 = new TextBox();
                    //s=name[(k-1)];
                    s = "l2";
                    s += i.ToString();
                    l2.ID = s;
                    //l2.Font.Bold = true;
                    l2.Style["Position"] = "Absolute";
                    //l.Style["Top"] = "25px";
                    l2.Style["Left"] = "10px";
                    l2.EnableViewState = true;

                    s = string.Empty;
                    s = " Descriptors";
                    s += i.ToString();
                    l2.Text = TextBox6.Text;

                    s = string.Empty;
                    s = "t2";
                    s += i.ToString();
                    t2.ID = s;
                    s = string.Empty;
                    s = "Text";
                    s += i.ToString();
                    //te.Text = s;
                    t2.Style["Position"] = "Absolute";
                    //t.Style["Top"] = "25px";
                    t2.Style["Left"] = "100px";
                    t2.EnableViewState = true;
                    LiteralControl lc = new LiteralControl();
                    lc.Text = "<BR><BR>";
                    Panel4.Controls.Add(l2);
                    Panel4.Controls.Add(t2);
                    Panel4.Controls.Add(lc);


                }
                else if (ln == "C")
                {

                    string s = string.Empty;
                    l3 = new Label();
                    t3 = new TextBox();
                    dl = new DropDownList();
                    s = "l3";
                    s += i.ToString();
                    l3.ID = s;
                    //l3.Font.Bold = true;
                    l3.Style["Position"] = "Absolute";
                    //l.Style["Top"] = "25px";
                    l3.Style["Left"] = "10px";
                    l3.EnableViewState = true;
                    s = string.Empty;
                    s = " Choices";
                    s += i.ToString();
                    l3.Text = TextBox8.Text;

                    s = string.Empty;
                    s = "t3";
                    s += i.ToString();
                    t3.ID = s;
                    s = string.Empty;
                    s = "Text";
                    s += i.ToString();
                    //tex.Text = s;
                    t3.Style["Position"] = "Absolute";
                    //t.Style["Top"] = "25px";
                    t3.Style["Left"] = "100px";
                    t3.EnableViewState = true;

                    s = string.Empty;
                    s = " List";
                    s += i.ToString();
                    dl.ID = s;
                    dl.Style["Position"] = "Absolute";
                    //l.Style["Top"] = "25px";
                    dl.Style["Left"] = "260px";
                    dl.Width = 150;
                    dl.EnableViewState = true;

                    LiteralControl lc = new LiteralControl();
                    lc.Text = "<BR><BR>";
                    Panel4.Controls.Add(l3);
                    Panel4.Controls.Add(t3);
                    Panel4.Controls.Add(dl);
                    Panel4.Controls.Add(lc);

                }
                else if (ln == "F")
                {

                    string s = string.Empty;
                    l4 = new Label();
                    t4 = new TextBox();
                    lb = new ListBox();
                    s = "l4";
                    s += i.ToString();
                    l4.ID = s;
                    //l4.Font.Bold = true;
                    l4.Style["Position"] = "Absolute";
                    //l.Style["Top"] = "25px";
                    l4.Style["Left"] = "10px";
                    s = string.Empty;
                    s = " Choices1";
                    //s += i.ToString();
                    l4.Text = TextBox9.Text;
                    l4.EnableViewState = true;

                    s = string.Empty;
                    s = "t4";
                    s += i.ToString();
                    t4.ID = s;
                    s = string.Empty;
                    s = "T4";
                    s += i.ToString();
                    //text.Text = s;
                    t4.Style["Position"] = "Absolute";
                    //t.Style["Top"] = "25px";
                    t4.Style["Left"] = "100px";
                    t4.EnableViewState = true;

                    s = string.Empty;
                    s = " ListBox";
                    s += i.ToString();
                    lb.ID = s;
                    //dl.ID = s;
                    lb.Style["Position"] = "Absolute";
                    ////dl.Style["Position"] = "Absolute";
                    ////l.Style["Top"] = "25px";
                    lb.Style["Left"] = "260px";
                    //dl.Style["Left"] = "260px";
                    lb.Width = 150;
                    lb.Height = 100;
                    //dl.Width = 150;
                    lb.EnableViewState = true;
                    LiteralControl lc = new LiteralControl();
                    lc.Text = "<BR><BR><BR><BR><BR>";
                    Panel4.Controls.Add(l4);
                    Panel4.Controls.Add(t4);
                    Panel4.Controls.Add(lb);
                    Panel4.Controls.Add(lc);

                }

                ln = tr.ReadLine();
                i++;
            }

            tr.Close();
        }

        catch (IOException io)
        {
            throw new IOException(io.Message);
        }


    }


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically generated dropdownlist csun ASP.NET 1.0 and 1.1 Basics 3 April 8th, 2008 07:38 AM
dynamically generated form SaraJaneQ Javascript How-To 4 November 9th, 2006 11:11 AM
dynamically generated submenus elladi Dreamweaver (all versions) 9 December 24th, 2004 08:12 AM
dynamically generated pop up menus... elladi Dreamweaver (all versions) 7 August 1st, 2004 03:31 AM



All times are GMT -4. The time now is 09:05 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.