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
-
Both your requirements are a little vague, and probably separate issues. Could you show us what you have tried to do?Josh– Josh2011-10-03 12:39:25 +00:00Commented Oct 3, 2011 at 12:39
-
It's usually better if you post some code so we can see where you are.James Johnson– James Johnson2011-10-03 14:04:06 +00:00Commented Oct 3, 2011 at 14:04
Add a comment
|
2 Answers
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!!
Comments
Here is some research for you that should get you headed in the right direction.