开发者

How to create dynamic textbox using asp.net and C#

How 开发者_如何学Pythonto 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


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!!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜