1

How to create dynamic textbox using asp.net and C# .how to store in database .please any one help me i am new to this .Thanks in advance

2
  • Both your requirements are a little vague, and probably separate issues. Could you show us what you have tried to do? Commented Oct 3, 2011 at 12:39
  • It's usually better if you post some code so we can see where you are. Commented Oct 3, 2011 at 14:04

2 Answers 2

1

I hope this can help you: For Data access you can take a look here: 1. http://www.asp.net/web-forms 2. Download "Professional Asp.Net 4 (wrox)" or "Microsoft ASP.NET 4 Step by Step"

And the code for add textbox(in this case)dinamically in a gridview is like this

void addTextBoxInGridView()
        {
            int nr = 0, nc = 0;
            nr = this.GridView1.Rows.Count;
            if (nr > 0)
            {
                nc = this.GridView1.HeaderRow.Cells.Count;

                int r = 0, c = 0;
                for (r = 0; r < nr; r++)
                {
                    for (c = 0; c < nc; c++)
                    {
                        string v1 = "";
                        v1 =    HttpUtility.HtmlDecode(this.GridView1.Rows[r].Cells[c].Text.ToString());

                        TextBox textbox = new TextBox();
                        textbox.Text = v1;
                        textbox.EnableViewState = true;
                        textbox.Style["text-align"] = "center";
                        textbox.Width = 40;
                        textbox.ID = "txt" + Convert.ToString(r) + Convert.ToString(c);
                        this.GridView1.Rows[r].Cells[c].Controls.Add(textbox);
                    }
                }
            }

        }

Happy code!!

Sign up to request clarification or add additional context in comments.

Comments

0

Here is some research for you that should get you headed in the right direction.

Adding Controls to page dynamically

Data Access in ASP.Net

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.